简体   繁体   English

引导程序中具有不同图像大小的图像库

[英]Image gallery with different image sizes in bootstrap

I have two images with two different size. 我有两个具有两个不同大小的图像。 I am using bootstrap in my project. 我在项目中使用引导程序。 But I cant place the images together which looks like both have same dimension. 但是我无法将看起来像具有相同尺寸的图像放在一起。 I have gone through similar questions and tried a lot. 我经历了类似的问题并尝试了很多。 Please help me to sort this out. 请帮我解决这个问题。

   <div class="row">
  <div class="col-md-4">
  <div class="thumbnail">
    <a href="http://placehold.it/2048x1536" target="_blank">
      <img src="http://placehold.it/2048x1536" alt="Nature">
    </a>
  </div>
</div>

<div class="col-md-4">
  <div class="thumbnail">
    <a href="http://placehold.it/1280x720" target="_blank">
      <img src="http://placehold.it/1280x720" alt="Nature">
    </a>
  </div>
</div>

my css is 我的CSS是

.thumbnail img {
height:250px;
width:100%;
}

You can do it by putting the picture as background-image for the 'div' tag and setting value of 'background-position' as 'stretch'. 您可以通过将图片作为'div'标签的背景图像并将'background-position'的值设置为'stretch'来实现。

Said that, if the images are of different resolution and you fit them into the same-size container it might look pixelated at times. 也就是说,如果图像具有不同的分辨率,并且将它们放入相同大小的容器中,则有时可能看起来像素化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM