【问题标题】:Vertical align two lines of text with image bootstrap 3使用图像引导程序 3 垂直对齐两行文本
【发布时间】:2014-09-11 21:56:04
【问题描述】:

我试图在 Bootstrap 3 中垂直对齐两行文本和一个图像。图像总是相同的大小。当我在希望中断发生的行之间添加<br> 标记时,它会将第二行向下移动到图像下方。

Bootply demo here

<div class="col-xs-12 col-md-6">
  <img style="vertical-align:middle; max-height:100px;" src="http://placehold.it/100x150">
  <span class="bold">Product Name</span>
  <button name="remove" value="1" type="submit" class="font-tiny btn-link">Remove</button>

  <br> <!--this is where I would like to create line break-->
  <span class="small text-light">From "Company Name"</span> 

</div>

有人知道怎么做吗?我遇到了其他看起来相关但与引导程序 3 无关的问题。谢谢

【问题讨论】:

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


    【解决方案1】:

    或者像这样正确地做 - 真正的引导

    http://www.bootply.com/QtLoWTnmi9

    <div class="col-xs-12 col-md-6">
        <div class="col-md-2">
            <img class="image" src="http://placehold.it/100x150">
        </div>
        <div class="col-md-6 alignme">
            <span class="bold">Product Name</span>
            <button name="remove" value="1" type="submit" class="font-tiny btn-link">Remove</button>
            <br>        
            <span class="small text-light">From "Company Name"</span> 
        </div>
    </div>
    

    【讨论】:

      【解决方案2】:

      这应该可以解决问题:

      <div class="col-xs-12 col-md-6">
      
        <div style="display:table-cell; vertical-align: middle">
          <img style="vertical-align:middle; max-height:100px;" src="http://placehold.it/100x150">
        </div>
      
        <div style="display: table-cell; vertical-align: middle; padding-left: 10px;">
          <span class="bold">Product Name</span>
          <button name="remove" value="1" type="submit" class="font-tiny btn-link">Remove</button>
          <br>
          <span class="small text-light">From "Company Name"</span>
        </div>
      
      </div>
      

      【讨论】:

      • @ruben 你在教坏习惯.. 内联样式而不是使用 bootraps 自己的列
      • 我同意 padding-left 不是很好,但是在这种情况下它对我有用
      • @nol 如果引导列不提供垂直对齐元素的方法,我为什么要使用它们?
      • @RubenKislaki 如果要修改,您可以随时将类添加到列中。 valign 用的不多stackoverflow.com/questions/20547819/…
      【解决方案3】:

      向左浮动您的图像。 float: left;

      【讨论】:

        猜你喜欢
        • 2013-01-14
        • 1970-01-01
        • 1970-01-01
        • 2021-04-03
        • 2014-09-28
        • 2017-01-12
        • 1970-01-01
        • 2013-03-23
        • 2017-05-09
        相关资源
        最近更新 更多