[英]Vertical align two lines of text with image bootstrap 3
I am trying to vertically align two lines of text and an image in Bootstrap 3. The image is always going to be the same size. 我正在尝试在Bootstrap 3中垂直对齐两行文本和一个图像。图像将始终具有相同的大小。 When I add a <br>
tag between the lines where I want the break to occur, it moves the second line down below the image. 当我在希望中断的行之间添加<br>
标记时,它将第二行向下移动到图像下方。
<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>
Does anyone know how to do this? 有谁知道如何做到这一点? I have come across other questions that appear related but not for bootstrap 3. Thanks 我遇到了其他相关问题,但与bootstrap 3无关。谢谢
This should do the trick: 这应该可以解决问题:
<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>
Float your image left. 向左浮动图片。 float: left;
or do it right like this - true bootstrap 或像这样正确做-真正的引导程序
http://www.bootply.com/QtLoWTnmi9 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.