
[英]Bootstrap 4 Carousel Scale different sizes images not working properly
[英]Have Thumbnails with different images sizes 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>
您可以通过定义容器的尺寸来实现这一目的。
例如,在您的容器元素(.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;
}
与其他元素等等。
你可以用img
标签上的CSS完成这个。
img {
width: 200px;
height: 200px;
}
或者像这样嵌入每个img
标签
<img style="width: 200px; height: 200px" src="https://learn.adafruit.com/system/guides/images/000/000/339/medium310/overview_web.jpg" alt="Sample Image">
您应该设置这些列的高度。 在示例中,我们具有相同数量的文本,因此每个div具有相同的高度。
这是我的解决方案,希望对您有所帮助!
<style type="text/css">
.row{
display: flex;
flex-wrap: wrap;
}
.row>[class="col-sm-6 col-md-4"]{
display: flex;
flex-direction: column;
}
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.