Rumah  >  Artikel  >  hujung hadapan web  >  框覆盖时会覆盖背景但不覆盖文字,如何设置?_html/css_WEB-ITnose

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

WBOY
WBOYasal
2016-06-21 09:40:182315semak imbas

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

回复讨论(解决方案)

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

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

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn