【问题标题】:Structuring thumbnails on bootstrap在引导程序上构建缩略图
【发布时间】:2023-03-27 01:39:02
【问题描述】:

所以我遇到了定位和对齐缩略图的问题。我想在 div 上放置固定的宽度和高度,但是当我使用 Bootstrap 时,我已经放置了 col-md 和 col-xs 以提高响应能力,现在我无法弄清楚如何适应每个图像,无论它有多大是一个固定的宽度和高度。我尝试过百分比和像素,但随后它失去了移动性和响应能力,并保持在该宽度上。这是问题的图片http://postimg.org/image/n4tnblczd/。我会非常感谢一些建议如何将大图片调整为固定的宽度和高度,但要保持它的响应能力。

【问题讨论】:

  • 你能和我们分享你的代码吗?
  • 请展示你目前拥有的东西和一个可运行的例子

标签: html css twitter-bootstrap


【解决方案1】:

在提问之前建议提供您的示例代码。我想你想知道html结构的过程。 使用下面的 html 代码进行引导支持。 div 类中的 col-md 和 col-sm。 img 类将是“img-responsive”。它会得到 bootstrap.min.css

<div class="col-md-6 col-sm-6 col-xs-12 text-left">
    <img src="/images/choose-us.png" class="img-responsive">
</div>

使用这个我想它会解决你的问题。这是我使用不同图像大小的 css 应用的屏幕截图。

由于引导 css 链接,下面的 sn-p 代码没有显示确切的样式。

.thumbnail{
padding: 0px;
border-radius: 0px;
position: relative;
border: 1px solid #222;
}


.thumbnail img{
 height: 347px;
}
.drzac{
margin-top: 30px;
}

.overlay{
display: block;
transition: all 0.3s;
-webkit-transition: all 0.3s;
background-color: rgba(50, 200, 235, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
font-size: 2em;
text-align: center;
}
<div class="col-xs-6 col-md-4">
				<div class="thumbnail">
				<img src="http://www.it4gen.com/wp-content/uploads/2013/02/learnindoorgrowing.com_-460x345.png" class="img-responsive">
				    <a href="#" class="overlay"><div class="centered"><i class="fa fa-search"></i></div></a>
				</div>
</div>

<div class="col-xs-6 col-md-4">
				<div class="thumbnail">
				<img src="http://www.totalcableusa.com/images/choose-us.png">
				    <a href="#" class="overlay"><div class="centered"><i class="fa fa-search"></i></div></a>
				</div>
</div>
    
    <div class="col-xs-6 col-md-4">
				<div class="thumbnail">
				<img src="http://www.totalcableusa.com/images/choose-us.png">
				    <a href="#" class="overlay"><div class="centered"><i class="fa fa-search"></i></div></a>
				</div>
    </div>

【讨论】:

  • 这是我使用不同尺寸的不同图片的示例,但有些比其他的要小。 jsfiddle.net/ognjengt/fmhopnjv
  • 您可以通过定义容器的尺寸来实现这一点。例如,在您的容器 div 中,设置要遵循的特定尺寸,例如:.thumbnail img{ height: 347px;}
  • 试过了,但它在所有尺寸上都保持不变,我想我会采用这种方法并使用 @media 查询来修改某些分辨率
  • 是的,您可以使用@media 查询。
猜你喜欢
  • 2015-12-08
  • 2012-06-22
  • 2016-04-02
  • 2013-01-01
  • 2014-11-20
  • 1970-01-01
  • 2015-11-02
  • 2014-05-20
  • 1970-01-01
相关资源
最近更新 更多