0
我爲導航欄創建了一個漢堡圖標。外部容器固定,絕對定位內部條。問題是,當我將top屬性應用到外部固定元素時,它會影響內部條的高度。爲什麼會發生這種情況,我該如何阻止它?影響內部絕對定位元素的固定元素頂部屬性
下面是我創建了一個小演示:
div{
position: fixed;
/*top: 3.4em; /*uncomment this to see the problem*/
right: 5em;
height: 2em;
width: 2em;
cursor: pointer;
z-index: 50;
background-color: #ffffff;
border: 0.063em solid #ff6633;
border-radius: 0.313em;
}
span{
display: block;
position: absolute;
height: 0.2em;
width: 1.5em;
background-color: #ff6633;
left: 0.25em;
}
span:nth-child(1){
top: 0.25em;
}
span:nth-child(2){
top: 0.863em;
}
span:nth-child(3){
top: 1.438em;
}
<div>
<span></span>
<span></span>
<span></span>
</div>
https://jsfiddle.net/ezp43625/
它工作正常 –
您是否嘗試取消註釋頂部屬性以查看問題? – Reece
嘗試在'pixels' –