1 回答

TA貢獻1744條經驗 獲得超4個贊
這是因為順序的原因,在正常流程中,唯一存在的堆棧上下文是 ,<html>并且元素將被標記中緊隨其后的下一個元素覆蓋。
使用 z-index 會影響某些元素的渲染順序,但是 z-index 不會產生任何影響,因為 z-index 僅適用于定位元素。
定位元素:是位置值不是static的元素
我們可以使用,position:relative因為它的行為類似于靜態。
a {
color: lightblue;
transform: scale(1);
transition: all 1s;
display: inline-block;
background-color: transparent;
z-index: 1;
}
a:hover {
transform: scale(5);
background-color: yellow;
position: relative;
z-index: 2; /* higher than other <a> */
}
/* Just to center Not needed */
div {
display: table;
margin: 5em auto;
}
<div class="page-footer">
<a href="">ABCD</a> /
<a href="">EFGH</a> /
<a href="">IJKL</a>
</div>
- 1 回答
- 0 關注
- 142 瀏覽
添加回答
舉報