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

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

WBOY
WBOYOriginal
2016-06-21 09:40:182314browse

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

回复讨论(解决方案)

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

设置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越大 ,离用户越近

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn