18910140161

HTML-将三个图像并排放置并填充父图像-堆栈溢出

顺晟科技

2022-10-18 14:06:56

161

我想有三个图像并排在一起,有一个条件,我无法达到没有一点点的帮助:

.picture-container {
  position: absolute;
  top: 10%; 
  width: 90%;
  height: 70%;
  left: 5%;
  border-style: dotted;
}



.picture-container .img-container.three-image {
  justify-items: center;
  height: 100%;
  gap: 20px;
  display: grid;
  grid-template-columns: auto auto auto;
}

.picture-container .img-container.three-image * {
    height: 298px;
}

.picture-container .img-container.three-image .img-frame {
  width: 100%;
  height: 42%;
  object-fit: cover;
}

.img-frame {
    display: flex;
    border: 5px solid #e8e8e8;
  box-shadow: 1px 7px 20px 9px rgb(0 0 0 / 75%);
    margin: 3rem auto 3rem;
    flex: 1 0 45%;
    border-radius: 5px;
    cursor: pointer;
    margin: 0.4rem;
    background: #dfe4ea;
    user-select: none;
    transition: 0.5s;
    height: 100%;
  object-fit: contain;
}
<代码><;DIV类=“图片容器”>;<;DIV Class=“ IMG-container three-image ”>;<;IMG CLASS=“ IMG-frame ” SRC=“ https://images.pexels.com/photos/4876243/pexels-photo-4876243.jpeg?auto=compress&cs=tinysrgb&;dpr=1&w=500 ”>;<;IMG CLASS=“ IMG-frame ” SRC=“ https://images.pexels.com/photos/1386454/pexels-photo-1386454.jpeg?auto=compress&cs=tinysrgb&;dpr=1&w=500 ”>;<;IMG CLASS=“ IMG-frame ” SRC=“ https://images.pexels.com/photos/9646282/pexels-photo-9646282.jpeg?auto=compress&cs=tinysrgb&;dpr=1&w=500 ”>;<;/DIV>;<;/DIV>;

我希望这些图像:

  1. 填充<div class="picture-container"> <div class="img-container three-image "> <img class="img-frame" src="https://images.pexels.com/photos/4876243/pexels-photo-4876243.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"> <img class="img-frame" src="https://images.pexels.com/photos/1386454/pexels-photo-1386454.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"> <img class="img-frame" src="https://images.pexels.com/photos/9646282/pexels-photo-9646282.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"> </div> </div>父级的整个区域。它们应该填充picture-container的宽度和高度。

  2. 所有图像都应具有相同的尺寸。我不想有不同的尺寸。

请注意,每个图像的源都有自己的尺寸。

图像不应该被裁剪,它们可以被拉伸。

框架应该完好无损。

怎么能这么做?


顺晟科技:

如果不将图像包装在一个DIV中,并在图像本身上设置宽度和高度,

我就无法让它工作。

picture-container

示例:https://jsfiddle.net/540scey8/1/.

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航