【发布时间】:2014-02-04 06:19:54
【问题描述】:
我需要垂直和水平居中的文本。我正在制作一个带有圆形背景的链接,我需要它响应式,并且不能将 line-height 设置为链接的高度。原因如下:
html
<a class="Previous" href="#"> < </a>
<a class="Next" href="#"> > </a>
css
a.Previous, a.Next {
float: left;
text-decoration: none;
color: #fff;
width: 8%;
height: 0;
padding-bottom: 8%;
margin: 0 2% 0;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
display: inline-block;
background: black;
text-align: center;
vertical-align: middle;
}
我试过了
line-height: 0;
它不起作用。如何让我的文本在链接的响应背景中绝对居中?
【问题讨论】:
-
如果您对浏览器支持感到满意,我建议您查看 flexbox 解决方案。 - css-tricks.com/snippets/css/a-guide-to-flexbox
标签: html responsive-design vertical-alignment