之間不工作我有下面的文本框的圖像。我縮放了圖像,並且它越過了文本框,我不希望文本框位於圖像的頂部,但它不適用於z-index。
HTML:
<a href="#">
<img src="http://images.meredith.com/content/dam/bhg/Images/2009/07/101422234.jpg.rendition.200sq.jpg" />
<div class="text">
This is some text.
</div>
</a>
CSS:
a {
height:400px;
width:200px;
display:block;
text-decoration:none;
color:black;
overflow:hidden;
}
img {
transform: scale(1.1);
}
a:hover .text {
color:white;
background-color:black;
}
.text {
text-align:center;
height:200px;
margin-top:-4px;
background-color:white;
transition:all 1s ease;
}
看你的代碼,我看你有沒有添加的位置屬性的元素..和z-index僅適用於定位元素(位置:絕對,位置:相對或位置:固定)。看到這裏:https://www.w3schools.com/cssref/pr_pos_z-index.asp ...所以嘗試添加位置:相對;同時使用z-index – Sarah