我正在尝试使用Bootstrap 3中的
但上述方法并不能解决问题,在这里我创建了一个CodePen示例,以重现这个问题。
list-group-item
来实现文本和按钮的垂直对齐。我已经试过将父元素a
设为display: table;
,内部的div设置为display: table-cell;
,以便使用vertical-align: middle
。但上述方法并不能解决问题,在这里我创建了一个CodePen示例,以重现这个问题。
Although for some reason if I post the same code here in SO snippet it seems to be working. However, when I render that in my HTML document it won't work.
a {
overflow: hidden;
display: table;
}
a > div {
display: table-cell;
vertical-align: middle;
}
.btn {
width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="list-group">
<!-- ngRepeat: value in results -->
<a href="/store/products/testing" class="list-group-item search-product ng-scope" ng-repeat="value in results">
<div class="media col-md-3">
<figure class="pull-left">
<img class="media-object img-rounded img-responsive" src="http://lorempixel.com/500/500" alt="Testing">
</figure>
</div>
<div class="col-md-6">
<h4 class="list-group-item-heading ng-binding"> Test product </h4>
<p class="list-group-item-text ng-binding" ng-bind-html="value.short_description | to_trusted">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et…</p>
</div>
<div class="col-md-3 text-center">
<div ng-controller="postDataToCartCtrl" class="ng-scope">
<form url="store/addtocart" ng-submit="add(value.id, 1)" class="ng-pristine ng-valid">
<input name="quantity" type="hidden" value="1">
<button type="submit" class="btn btn-success">
<span class="glyphicon glyphicon-shopping-cart"></span> Add to Cart
</button>
</form>
</div>
</div>
</a>
<!-- end ngRepeat: value in results -->
</div>
</div>