【发布时间】:2017-03-09 12:45:43
【问题描述】:
尝试在响应式水平列表中垂直对齐多行文本(链接)。我的导航高度是固定的。
我的标记重组是这样的。你可以看到所有的链接都有均匀分布的宽度,如果容器变小了,第三个链接项会跨越多行,我怎样才能让它垂直对齐?
.list {
font-family: arial;
background: white;
margin: 0;
padding: 0;
list-style: none;
display: table;
width: 100%;
table-layout: fixed;
}
.list-item {
display: table-cell;
text-align: center;
vertical-align: middle;
}
.list-item a {
box-sizing: border-box;
display: block;
color: #fff;
text-decoration: none;
font-size: 12px;
background: blue;
padding: 0 15px;
line-height: 48px;
min-height: 48px;
max-height: 48px;
}
.list-item a:hover {
background: red;
}
<ul class="list">
<li class="list-item"><a href="">one</a></li>
<li class="list-item"><a href="">two</a></li>
<li class="list-item"><a href="">three three three</a></li>
<li class="list-item"><a href="">four</a></li>
<li class="list-item"><a href="">five</a></li>
</ul>
【问题讨论】:
标签: html css navigation responsive