日期:2014-05-17  浏览次数:20664 次

框覆盖时会覆盖背景但不覆盖文字,如何设置?

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

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

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