Maison  >  Article  >  interface Web  >  框覆盖时会覆盖背景但不覆盖文字,如何设置?_html/css_WEB-ITnose

框覆盖时会覆盖背景但不覆盖文字,如何设置?_html/css_WEB-ITnose

WBOY
WBOYoriginal
2016-06-21 09:40:182315parcourir

上面的框可以覆盖下面框的背景,但不会覆盖下面的文字,应如何设置?

回复讨论(解决方案)

发下代码看看,不然不好说

设置z-index的值,http://www.w3school.com.cn/css/pr_pos_z-index.asp

 
hello
 hello
test   


hello2
test2


上面的test能够透过背景色看到。

position:relative;
定位可以吧,在两个style都加上这个

<div style=" border:1px solid red; width:50px; position:absolute ; background-color: gray;  z-index:10; "  > hello<br/> hello<br/>test   </div><div style=" border:1px solid green; width:50px;position:absolute; background-color: yellow;  z-index:0; top:30px;  "  >hello2<br></br>test2</div>

position改成absolute以后就可以用z-index设置它了,z-index越大 ,离用户越近

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn