【发布时间】:2017-01-09 21:05:51
【问题描述】:
好的,我很有趣引导程序并且有一些带有文本的缩略图框(见下面的代码)。
我还希望垂直和水平对齐文本,我使用flexbox 完成了此操作,这似乎可行,但是现在span、h4 和p 标记都在同一行而不是比stacked。
什么是解决这个问题的最佳方法,所以我得到标签stacked,但同时水平和垂直居中。
HTML
<div class="col-md-3 overlord-thumbnail">
<div class="thumbnail">
<a href="#tab4" data-toggle="tab">
<div class="caption">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
<h4>Latest News</h4>
<p>text here</p>
</div>
</a>
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
<h4> Latest News</h4>
<p>text here</p>
</div>
</div>
CSS
.overlord-thumbnail {
height: 188px;
overflow-y: hidden;
overflow-x: hidden;
}
.thumbnail {
background: whitesmoke;
border-radius: 0;
height: 100%;
display: -moz-box;
display: -ms-flexbox;
display: inline-flex;
-moz-box-pack: center;
-ms-flex-pack: center;
-moz-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.caption {
position:absolute;
top:-100%;
right:0;
background: rgba(66, 139, 202, 0.64);
width:100%;
height:100%;
padding:2%;
text-align:center;
color:#fff !important;
z-index:2;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.thumbnail:hover .caption {
top:0;
}
目前
应该是
【问题讨论】:
-
您想要最新消息、此处的文字和一行中的图标吗?
-
不,我希望它们像没有显示的那样堆叠:inline-flex;
-
@BenjaminOats .. 看看我的回答,这就是你想要的吗?
标签: html css twitter-bootstrap flexbox