【发布时间】:2017-10-07 13:23:00
【问题描述】:
我有 4 列在移动设备上变成 1 列。这在移动设备上看起来很好,但我想将每行的 div 2 和 4 中的内容居中。最好的方法是什么?
显然我的编辑被删除了,或者网站搞砸了,但我说过我想做这个垂直和水平的。但是,我忘记链接到该页面是我的错。对不起大家。 - http://www.dismantledesign.com/testsite2/clients.html
编辑:我很欣赏所有的答案,但我认为没有人明白这个 div 没有设定高度。我只希望文本和图标在屏幕移动时保持居中。 flex 似乎不起作用,因为它需要为 div 设置高度。
我还简化了我的 HTML
代码
.clientsdetail {
text-align: center;
margin: 0px;
padding: 0px;
overflow-x: hidden;
}
.clientinfo h3 {
padding-top: 10px;;
}
.clientinfo p {
padding: 0px 30px;
font-size: 15px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-3 nopadding">
<img class="img-responsive" src="img/clients/ivey.jpg">
</div>
<div class="col-md-3 nopadding cinfo">
<div class="clientinfo text-center">
<h3>IVEY</h3>
<p>Clarksville, TN</p>
<div class="social-icons-clients">
<a href="#"><span class="icon-sprite sprite-ig"> </span></a>
<a href="#"><span class="icon-sprite sprite-fb"> </span></a>
<a href="#"><span class="icon-sprite sprite-gp"> </span></a>
<a href="#"><span class="icon-sprite sprite-sc"> </span></a>
<a href="https://twitter.com/contracoda" target="_blank"><span class="icon-sprite sprite-tw"> </span></a>
</div>
</div>
</div>
<div class="col-md-3 nopadding cinfo">
<img class="img-responsive" src="img/clients/rufus.jpg">
</div>
<div class="col-md-3 nopadding">
<div class="clientinfo text-center">
<h3>RUFUS DAWKINS</h3>
<p>Clarksville, TN</p>
<div class="social-icons-clients">
<a href="#"><span class="icon-sprite sprite-ig"> </span></a>
<a href="#"><span class="icon-sprite sprite-fb"> </span></a>
<a href="#"><span class="icon-sprite sprite-gp"> </span></a>
<a href="#"><span class="icon-sprite sprite-sc"> </span></a>
<a href="https://twitter.com/contracoda" target="_blank"><span class="icon-sprite sprite-tw"> </span></a>
</div>
</div>
</div>
</div>
【问题讨论】:
-
你忘了关闭 标签...
-
看起来我错过了这些精灵的跨度标签。感谢您指出这一点。
标签: html css twitter-bootstrap twitter-bootstrap-3