【问题标题】:Aligning responsive Bootstrap images with caption title text将响应式 Bootstrap 图像与标题文本对齐
【发布时间】:2014-12-31 22:00:40
【问题描述】:

我有这 3 列图片,其中包含我无法正确对齐的标题、标题广告图标。有没有办法根据图像宽度修复标题和标题文本?处理此类内容的最佳做法是什么?我应该为每个屏幕尺寸对齐 CSS 吗?

@import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css');
 .urun-text {
  position: absolute;
  background-color: rgba(15, 15, 15, 0.93);
  color: #fff;
  bottom: 0px;
  text-align: left;
  padding: 20px 15px 20px 15px;
}
.urun-title {
  position: absolute;
  bottom: 80px;
  text-align: left;
  z-index: 15;
  padding-top: 5px;
  padding-bottom: 5px;
  color: #fff;
  padding-left: 20px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  background-color: rgba(194, 0, 0, 0.93);
  width: 100%;
}
.click-arrow-right {
  position: absolute;
  z-index: 16;
  color: #fff;
  font-size: 10px;
  bottom: 0px;
  right: 33px;
}
<div class="container">
  <div class="row">
    <div class="col-md-4">
      <div class="product-box">
        <img src="http://i.imgur.com/xkAVZ3b.jpg" alt="Yeni Ürünler" class="align-center img-responsive">
        <div class="urun-title"><span class="glyphicon glyphicon-star"></span> YENİ ÜRÜNLER</div>
        <div class="urun-text">En yeni mobilya konseptlerini görmek için tıklayınız.</div>
        <div class="click-arrow-right"><span class="glyphicon glyphicon-arrow-right"></span>
        </div>
      </div>
    </div>
    <div class="col-md-4">
      <div class="product-box">
        <img src="http://i.imgur.com/xkAVZ3b.jpg" alt="Yeni Ürünler" class="align-center img-responsive">
        <div class="urun-title"><span class="glyphicon glyphicon-star"></span> YENİ ÜRÜNLER</div>
        <div class="urun-text">En yeni mobilya konseptlerini görmek için tıklayınız.</div>
        <div class="click-arrow-right"><span class="glyphicon glyphicon-arrow-right"></span>
        </div>
      </div>
    </div>
    <div class="col-md-4">
      <div class="product-box">
        <img src="http://i.imgur.com/xkAVZ3b.jpg" alt="Yeni Ürünler" class="align-center img-responsive">
        <div class="urun-title"><span class="glyphicon glyphicon-star"></span> YENİ ÜRÜNLER</div>
        <div class="urun-text">En yeni mobilya konseptlerini görmek için tıklayınız.</div>
        <div class="click-arrow-right"><span class="glyphicon glyphicon-arrow-right"></span>
        </div>
      </div>
    </div>
  </div>
  </div

【问题讨论】:

  • 修好了,没注意到小提琴的问题,对此感到抱歉。

标签: html css image twitter-bootstrap-3 caption


【解决方案1】:

给你

http://jsfiddle.net/ajruk60t/3/

.product-box { 
    display:inline-block;
    position:relative;
}

.urun-title {
    width:100%;

}

.urun-text {
    width:100%;

}

将显示设置为inline-block 允许.product-box 仅与它的内容(即图像)一样宽,position:relative 允许我们设置嵌套的.urun-title.urun-text 的宽度元素为 .product-box 宽度的 100%。

【讨论】:

  • 还将width: 100% 添加到.urun-text
  • 这仅在将width: 100% 添加到.product-box 后对我有效
猜你喜欢
  • 1970-01-01
  • 2019-05-07
  • 2020-07-24
  • 2017-06-23
  • 2021-01-16
  • 2019-08-24
  • 2017-10-01
  • 1970-01-01
  • 2013-08-31
相关资源
最近更新 更多