【发布时间】:2017-08-14 11:25:18
【问题描述】:
我有一个响应式背景图像,因此在调整屏幕大小时它的宽度和高度会发生变化。在那个背景下,有一个绝对位置的元素。 现在,我的问题是,在调整屏幕大小时,绝对定位的元素不会跟随它在背景图像上的位置......
这是我的 HTML 代码:
<section id="all">
<div id="clicked1">
<img class="box" src="factory.svg" width="100%" height="auto">
</div>
</section>
CSS:
#all {
width: 100%;
height: 600px;
position: relative;
max-width: 1240px;
background: url('beach_to_meter.svg') no-repeat;
}
#clicked1 {
position: absolute;
left: 27%;
top: 28%;
z-index: 100;
width: 200px;
}
#clicked1 .box {
width:14vw;
max-width: 180px;
}
全屏是这样的: enter image description here 但是当屏幕变小时,绝对定位的元素会移动,像这样: enter image description here 在此输入代码
【问题讨论】:
标签: css responsive-design background css-position absolute