css - Bootstrap 中的缩略图类

标签 css html twitter-bootstrap-3

问题

因此,我尝试将 3 张图片排成一行。每个图像都有不同的维度。 所以,我尝试添加缩略图类,希望它能使所有图像大小相同,但它只添加了边框,而没有改变图像大小。

我想要什么

我希望所有图片大小相同。

代码

(代码是针对一张图片的,因为所有图片都有相同的代码)

<div class="col-lg-4">
     <div class="thumbnail">
      <img src="https://images.unsplash.com/photo1423034816855245e5820ff8cdpr=1&auto=format&fit=crop&w=1500&h=2000&q=80&cs=tinysrgb&crop="alt="Something in france!">
     </div>
</div>

最佳答案

你可以这样做,将 width: 100%;height: auto; 应用于 img

参见 fiddle用于工作演示

img{
  max-width: 100%;
  border: 1px solid red;
  width: 100%;
  height: 200px;  // adjust it based on your need
}

<div class="row">

  <div class="col-md-4 col-sm-4">
    <img src="http://placehold.it/500x150" />
  </div>
  <div class="col-md-4 col-sm-4">
    <img src="http://placehold.it/100x50" />
  </div>
  <div class="col-md-4 col-sm-4">
    <img src="http://placehold.it/200x150" />
  </div>

</div>

关于css - Bootstrap 中的缩略图类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40798877/

相关文章:

html - 为什么 <button> 中的绝对定位与 <div> 中的绝对定位不同

html - Bootstrap : How do I remove hover effect in CSS?

css - 导航栏的引导媒体查询不起作用

css - 如何将 360 滚动到 svg 组的中心?

javascript - 正确更改 z-index 以堆叠 SVG

java - 错误: Main method not found in class Example_Applet,

javascript - 如何在 carousel bootstrap 3 中添加视频

javascript - When option in select list doesn't fix into select width it's value is trimmed if we select it

div 第一个标题的 CSS 选择器

html - 使用 Bootstrap 3 样式化内联表单输入