具有不同图像大小的缩略图Bootstrap

Die*_*ego 18 html css jquery twitter-bootstrap

我想要有不同大小和不同文本数量的图像缩略图.但我希望它们都具有相同的尺寸.就像Bootstrap网站上的这个例子一样.

下面是我目前的代码,在jsFiddle上有一个演示.

我有不同的图像大小,所以这会被打破.Bootstrap有可能吗?

<div class="col-sm-6 col-md-4">
    <div class="thumbnail">
        <h3>
            Fading a RGB LED on BeagleBone Black
        </h3><img src="https://learn.adafruit.com/system/guides/images/000/000/322/medium310/overview_web.jpg?" alt="Sample Image">
        <div class="caption">
            <p>In this tutorial, you will learn how to control the color of an RGB LED using a BeagleBone Black and Python.</p>
        </div>
    </div>
</div>
<div class="col-sm-6 col-md-4">
    <div class="thumbnail">
        <h3>
            Measuring Light with a BeagleBone Black
        </h3><img src="https://learn.adafruit.com/system/guides/images/000/000/316/medium310/overview_web.jpg?" alt="Sample Image">
        <div class="caption">
            <p>In this tutorial, you will learn how to connect a photoresistor to a BeagleBone Black. The tutorial can also be used for other resistive sensors such as FSRs or SoftPots.</p>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

reu*_*lab 24

您可以通过定义容器的尺寸来实现这一目的.

例如,在您的容器元素(.thumbnail)中,设置一个特定的尺寸,如:

.thumbnail{        
    width: 300px; 
    // or you could use percentage values for responsive layout
    // width : 100%;
    height: 500px;
    overflow: auto;
}

.thumbnail img{
    // your styles for the image
    width: 100%;
    height: auto;
    display: block;
}
Run Code Online (Sandbox Code Playgroud)

与其他元素等等.

样品

  • 这不适用于响应式`col-xx-y`,但这是一个好主意.我甚至会说'溢出:隐藏' (3认同)