我的网页中的绝对定位有问题:
我想相对于其父按钮定位一个按钮,这就是我所做的:
.parent {
position: relative;
}
.child {
position: absolute;
top: 0px;
left: 0px;
}
.button {
height: 55px;
width: 180px;
background-color: transparent;
border-color: transparent;
background: url(Button.png);
background-size: 100% auto;
background-repeat: no-repeat;
}
<div class="parent" align="middle">
<img src="http://via.placeholder.com/1900" width="1900px" />
<div class="child">
<button class="button">Button</button>
</div>
</div>
此代码使按钮具有相对于窗口的位置,而不是它应该在的图像,所以当我缩小或按钮在图像内部移动时,而不是具有相同的相对位置。