>  기사  >  웹 프론트엔드  >  框覆盖时会覆盖背景但不覆盖文字,如何设置?_html/css_WEB-ITnose

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

WBOY
WBOY원래의
2016-06-21 09:40:182315검색

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

回复讨论(解决方案)

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

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

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.