<html><head><style type="text/css">hr {? ? width: 0.5%;? ? height: 45%;? ? border: none;? ? border-left: 2px dashed #60b654;? ? background-color: white;? ? position: absolute;? ? top: 10px;? ? left: 40px;? ? z-index: -1;}table{? ?width:20%;? ?height:30%;}#big{? ? width:200px;? ? height:100px;? ? position:absolute;? ? background:pink;}</style></head><body><div id="big"><tabel>? <tbody>? ? <tr>? ? ? <td>? ? ? ? ?<div style="background:red;width:50px;height:70px;">? ? ? ? ? ? <hr >?? ? ? ? ?</div>? ? ? </td>? ? </tr>?</tbody></tabel></div><h1>這是一個標(biāo)題</h1>?/* position ?子元素會繼承父元素的position屬性嗎,?求解答*/<p>默認(rèn)的 z-index 是 0。Z-index -1 擁有更低的優(yōu)先級。</p></body></html>
1 回答
已采納

stone310
TA貢獻(xiàn)361條經(jīng)驗 獲得超191個贊
因為hr的width: 0.5%;和?height: 45%;這兩個屬性意思是相對上一個擁有absolute或者relative定位的元素,如果未找到,則相對屏幕;
原來#big沒加上position:absolute的時候,height:45%是相對屏幕高度的45%,你可以看得見伸出來的那一部分;
現(xiàn)在設(shè)置了#big的定位,就是相對于#big了,相當(dāng)于#big的height的45%(即45px),然后z-index還是-1,所以就被擋住看不見了
添加回答
舉報
0/150
提交
取消