有没有其他方法可以在不同分辨率的特定位置的页面中定位图像

问题描述 投票:1回答:1

在这里iam尝试在第一部分中添加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>

enter image description here

css media-queries css-position
1个回答
1
投票

我只是用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>
© www.soinside.com 2019 - 2024. All rights reserved.