html - Bootstrap,如何以正确的方式将标题对齐到缩略图中图像的右侧,并将按钮对齐到标题的底部?

标签 html css twitter-bootstrap thumbnails caption

如标题所述,我正在使用 bootstrap v3.3.2 创建一个网站。

第一个问题是我使用网格系统将标题对齐到缩略图的右侧,如下所示:

<div class="container">

    <div class="thumbnail">

        <div class="row">

            <div class="col-md-6">

                <a href="#">

                    <img class="img-responsive" src="images/pic.jpg">

                </a>

            </div>

            <div class="col-md-6">

                <div class="caption">

                    <h2>Title</h2>

                    <hr>

                    <p>A design specification provides explicit information about the requirements for a product and how the product is to be put together. It is the most traditional kind of specification, having been used historically in public contracting for buildings, highways, and other public works, and represents the kind of thinking in which architects and engineers have been trained.</p>

                    <hr>

                    <p class="caption-footer">

                        <a href="#" class="btn"><span class="glyphicon glyphicon-heart"></span> Like it</a>

                        <a href="#" class="btn"><span class="glyphicon glyphicon-share"></span> Share it</a>

                    </p>

                </div>

            </div>

        </div>

    </div>

</div>

结果是这样的:

enter image description here

正如所注意到的,图像左侧有很大的边距,这并不理想。当我调整屏幕大小时,它变得更不受欢迎,两边都有很大的边距,如下所示:

enter image description here

我认为这可能是由网格系统引起的,因为 col-md-6 具有固定宽度。但是我不知道如何解决这个问题。

第二个问题是我尝试通过添加一个名为 caption-footer 的新类将两个按钮对齐到标题的底部。但是,这不起作用。

下面是我的 caption-footer 类 CSS 文件及其结果:

caption-footer{
  position: absolute;
  bottom:0;
  left: 0;
}

enter image description here

我在这里检查了很多链接(例如:link1 link2)。但它们似乎都不适用于我的情况。

在此先感谢您的帮助!

最佳答案

您可以做的一件事是将标题放在 col-md-12 div 下,将按钮放在另一个 col-md-12 div 下。

<div class="container">
  <div class="row">
    <div class="col-md-6">
      <a href="pulpitrock.jpg" class="thumbnail">
        <p>Pulpit Rock: A famous tourist attraction in Forsand, Ryfylke, Norway.</p>    
        <img src="pulpitrock.jpg" alt="Pulpit Rock" width="284" height="213">
      </a>
    </div>
    <div class="col-md-6">
      <div class="col-md-12">
           A design specification provides explicit information about the requirements for a product and how the product is to be put together. It is the most traditional kind of specification, having been used historically in public contracting for buildings, highways, and other public works, and represents the kind of thinking in which architects and engineers have been trained.
      </div>
      <div class="col-md-12">
               <a href="#" class="btn btn-primary">Download</a>
               <a href="#" class="btn btn-info">Images</a>
      </div>
    </div>
  </div>
</div>

关于html - Bootstrap,如何以正确的方式将标题对齐到缩略图中图像的右侧,并将按钮对齐到标题的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28391635/

相关文章:

html - Z Index 不适用,位置已经是相对/绝对的

html - 无处不在的大高度

javascript - CSS 菜单与 JavaScript 菜单

html - 单元格文本未换行(html 表格)

css - 设计 Twitter Bootstrap 搜索表单

javascript - Bootstrap 表插件在 'rtl' 表中不起作用

javascript - 在 Internet Explorer 的 ag-grid 中移动行选择选择额外的文本

css - 围绕 CSS 背景图像的边框

javascript - 如何在模式中将社交媒体按钮作为标题

html - Ipad show title-图片标签