#imgmenu {
position: fixed;
top: 0%;
left: 0%;
width: 100%;
height: 600px;
}
#icon img {
position: relative;
top: 70%;
left: 20%;
width: 3%;
height: 3%;
}
<div id="imgmenu">
<div id="icon">
<img src="crow.png" class="image" alt="">
</div>
</div>
左侧按预期工作 - 当窗口水平展开或压缩时,x位置会相应调整,但y位置似乎是固定的,并且在垂直更改窗口大小时不会调整。
答案 0 :(得分:1)
这是因为你已经将img声明为相对位置。如果我没有弄错的话,位置相对应该用于具有固定位置的元素,并且将是定位绝对元素的基础。
我认为你真正想要编码的是这个:
#imgmenu {
position: relative;
top: 0%;
left: 0%;
width: 100%;
height: 600px;
}
#icon img {
position: absolute;
top: 70%;
left: 20%;
width: 3%;
height: 3%;
}