-1
我目前正在用自定義絕對定位下拉菜單構建表單。其他輸入字段使用transform: translateY
進行動畫。不過,我根本無法讓下拉列表堆疊在下面的輸入元素之上。我已經簡化我的問題如下:使用變換堆疊絕對元素
HTML:
<div class="a"></div>
<div class="a top">
<div class="b"></div>
</div>
<div class="a"></div>
CSS:
.a {
transform: translateY(10px);
position: "relative";
background: red;
height: 50px;
margin-top: 10px;
z-index: 1;
opacity: 0.8;
}
.b {
position: "absolute";
top: 0;
height: 100px;
width:25px;
background: blue;
}
.input.top {
z-index: 10;
}
下小提琴說明我的問題: https://jsfiddle.net/m817ffqy/1/
我已經實驗過transform-style: flat
和設置translateZ
,但我一直沒有得到想要的效果。
雖然您對語法正確,但它似乎沒有在演示中有所作爲。另外,'.input.top'不起作用,因爲HTML中沒有'.input'類。另外,所有元素已經是「相對」或「絕對」了。 –