是否有任何替代方法可以将图像定位在不同分辨率的特定位置的页面中
Is there any alternative way to position images in a page at a particular place on different resolutions
这里我试图在部分中添加 2 张图片,一张居中对齐,第二张位于第一张图片旁边,但是我在使用以下代码时遇到了第二张图片在不同分辨率下的问题是否有在决议中保持一致的替代方法?
参考图片。
main.uni-design {
background-image: url("../images/ban2.jpg");
max-height: 1000px;
max-width: 100%;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
position: relative;
}
img.mob {
position: absolute;
bottom: -23px;
right: 0%;
}
@media only screen and (min-width: 768px) {
img.mob {
position: absolute;
bottom: -23px;
right: 7%;
}
}
@media only screen and (min-width: 992px) {
img.mob {
position: absolute;
bottom: -23px;
right: 16%;
}
}
@media only screen and (min-width: 1280px) {
img.mob {
position: absolute;
bottom: -23px;
right: 23%;
}
@media only screen and (min-width: 1400px) {
img.mob {
position: absolute;
bottom: -23px;
right: 27%;
}
<html>
<main class="uni-design pt-5">
<div class="container">
<h3>For all devices</h3>
<h3 class="bt">Unique design</h3>
<div class="clearfix"></div>
<img src="images/tab.png" class="img-fluid pt-4" />
<img src="images/mobnew.png" class="img-fluid mob" />
</div>
</main>
</html>
我刚刚使用 margin
用 flexbox 方法覆盖移动图像。希望对您有所帮助。
.res-design {
display: flex;
justify-content: center;
}
.res-design .mobile {
align-self: flex-end;
margin: 0 0 0 -8%;
border: 1px solid;
display: inline-block;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<main>
<div class="container my-5">
<div class="res-design">
<img src="https://via.placeholder.com/600x400.png" class="img-fluid tab" />
<img src="https://via.placeholder.com/150x200.png" class="img-fluid mobile" />
</div>
</div>
</main>
这里我试图在部分中添加 2 张图片,一张居中对齐,第二张位于第一张图片旁边,但是我在使用以下代码时遇到了第二张图片在不同分辨率下的问题是否有在决议中保持一致的替代方法? 参考图片。
main.uni-design {
background-image: url("../images/ban2.jpg");
max-height: 1000px;
max-width: 100%;
background-size: cover;
background-repeat: no-repeat;
text-align: center;
position: relative;
}
img.mob {
position: absolute;
bottom: -23px;
right: 0%;
}
@media only screen and (min-width: 768px) {
img.mob {
position: absolute;
bottom: -23px;
right: 7%;
}
}
@media only screen and (min-width: 992px) {
img.mob {
position: absolute;
bottom: -23px;
right: 16%;
}
}
@media only screen and (min-width: 1280px) {
img.mob {
position: absolute;
bottom: -23px;
right: 23%;
}
@media only screen and (min-width: 1400px) {
img.mob {
position: absolute;
bottom: -23px;
right: 27%;
}
<html>
<main class="uni-design pt-5">
<div class="container">
<h3>For all devices</h3>
<h3 class="bt">Unique design</h3>
<div class="clearfix"></div>
<img src="images/tab.png" class="img-fluid pt-4" />
<img src="images/mobnew.png" class="img-fluid mob" />
</div>
</main>
</html>
我刚刚使用 margin
用 flexbox 方法覆盖移动图像。希望对您有所帮助。
.res-design {
display: flex;
justify-content: center;
}
.res-design .mobile {
align-self: flex-end;
margin: 0 0 0 -8%;
border: 1px solid;
display: inline-block;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<main>
<div class="container my-5">
<div class="res-design">
<img src="https://via.placeholder.com/600x400.png" class="img-fluid tab" />
<img src="https://via.placeholder.com/150x200.png" class="img-fluid mobile" />
</div>
</div>
</main>