这里是我的小提琴Fiddle把文字在中间,这里是代码如何使一个圆圈,并使用CSS
.optionalphabetnumber {
\t background-color:#ff3333;
\t color:white;
\t width:20px;
\t height: 20px;
\t text-align:center;
border-radius:50%;
}
button {
background-color: #ffffff;
color: #777;
font-size: 18px;
height: 66px;
min-width: 320px;
width: 50%;
cursor: pointer;
text-align: left;
}
<button><span class="optionalphabetnumber">A </span>Superman</button>
我想提出“A”了一圈。但border-radius:50%
不是一个完美的圆圈。我如何将文本(只是“A”)放在中间?
你'span'需要为'边界半径矩形:50%;'来创建一个圆,而不是椭圆。如果元素是一个像“span”这样的内联元素,则不会发生这种情况。将显示更改为块级别,以便正确应用“高度”和“宽度”等尺寸属性。 – hungerstar