【发布时间】:2014-06-28 05:43:25
【问题描述】:
使用 html/css,我想创建一个带有两行居中文本的完美圆圈,如下图所示。在现代浏览器中工作的最干净/最优雅的方式是什么?我必须声明宽度和高度还是可以只使用填充/边框半径?
HTML
<h2 class="score">92 <br>
<span class="text">Overall</span>
</h2>
CSS
.score {
font-family: Arial;
text-align: center;
background: #DCAA38;
border-radius: 50%;
padding: 15px;
font-size: 30px;
color: #fff;
margin-bottom: 0;
}
.text {
position: relative;
margin-top: -20px !important;
font-weight: 100;
font-size: 12px;
}
【问题讨论】:
-
“最干净”是非常主观的。您想支持哪些浏览器?
-
为圆形或边框半径定义相等比例的宽度和高度 50% 将完成您在小提琴中看到的内容。除此之外,我不认为你的方法特别不干净(假设你正在做完全支持边界半径的技巧)