HTML
<div class="circle">
<div class="content">
<span><h3>heading</h3><p>slogan goes here</p></span>
</div>
</div>CSS
.circle {
position: relative;
width: 0;
height: 0;
padding: 20%;
margin: 1em auto;
border-radius: 50%;
background: #a7cd80;
}
.content {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: table;
overflow: hidden;
}
.content span{
display: table-cell;
vertical-align: middle;
text-align: center;
}
h3{
line-height: 1px;
}这段代码只适用于firefox,而不是chrome等。文本在firefox中显示为表格单元格,而在其他浏览器中则不显示,即文本仅在Firefox中以水平和垂直方向为中心。
演示
你可以从视觉上看到

发布于 2013-08-09 10:03:47
使用<div>对内容进行样式化,如本演示中所示。
https://stackoverflow.com/questions/18143669
复制相似问题