0
我已經創建了一個簡單的圖像疊加,將圖像與position:absolute
放置在另一個圖像上。使圖像疊加響應
在調整窗口大小時,圖像疊加失去了初始位置,導致兩個圖像分離。我需要他們堅持到相同的位置,直到屏幕達到移動寬度。
以下是代碼&這裏是一個codepen。
HTML -
<div class="projects">
<div id="images" class="stella">
<div class="desktop-image">
<img src="https:http://i3.mirror.co.uk/incoming/article10811001.ece/ALTERNATES/s1200/Arsenal-player-Alexandre-Lacazette-takes.jpg">
</div>
<div class="mobile-image-stella">
<img src="https:http://i3.mirror.co.uk/incoming/article10811001.ece/ALTERNATES/s1200/Arsenal-player-Alexandre-Lacazette-takes.jpg">
</div>
</div>
<div id="images" class="scf">
<div class="desktop-image">
<img src="https:http://i3.mirror.co.uk/incoming/article10811001.ece/ALTERNATES/s1200/Arsenal-player-Alexandre-Lacazette-takes.jpg">
</div>
</div>
<div id="images" class="misma">
<div class="desktop-image">
<img src="http://i3.mirror.co.uk/incoming/article10811001.ece/ALTERNATES/s1200/Arsenal-player-Alexandre-Lacazette-takes.jpg">
</div>
<div class="mobile-image-misma">
<img src="https:http://i3.mirror.co.uk/incoming/article10811001.ece/ALTERNATES/s1200/Arsenal-player-Alexandre-Lacazette-takes.jpg">
</div>
</div>
</div>
CSS -
.projects {
width: 100;
margin: 0 auto;
}
#images {
text-align: center;
padding-bottom: 230px;
}
#images img {
width: 50%;
height: 50%;
border: 5px solid #0f0f10;
}
.mobile-image-stella {
width: 30%;
position: absolute;
top: 112%;
left: 22%;
}
.mobile-image-misma {
width: 30%;
position: absolute;
top: 332%;
left: 22%;
}
這裏是一個媒體查詢,我爲了試圖解決這個問題
@media (min-width: 900px) and (max-width: 1428px) {
.mobile-image-stella {
width: 30%;
position: absolute;
top: 112%;
left: 22%;
}
.mobile-image-misma {
width: 30%;
position: absolute;
top: 332%;
left: 22%;
}
}
? –
在同一個位置,不管屏幕寬度 –
在大圖像上還是在哪裏? –