我需要将编号1对齐到红色圆圈的中心,但是无法实现。
#box {
background: red;
border-radius: 50% 50% 50% 50%;
color: #FFFFFF;
height: 50px;
text-align: center;
width: 50px;
}
如何让数字1在此方框中间居中?
我需要将编号1对齐到红色圆圈的中心,但是无法实现。
#box {
background: red;
border-radius: 50% 50% 50% 50%;
color: #FFFFFF;
height: 50px;
text-align: center;
width: 50px;
}
如何让数字1在此方框中间居中?
仅在水平方向上将文本居中对齐。您可以尝试这个:
#box {
background: red;
border-radius: 50% 50% 50% 50%;
color: #FFFFFF;
height: 50px;
text-align: center;
width: 50px;
vertical-align:middle;
display:table-cell
}
在元素的CSS中添加line-height: 50px;
。
#box {
background: red;
border-radius: 50% 50% 50% 50%;
color: #FFFFFF;
height: 50px;
text-align: center;
width: 50px;
line-height: 50px;
}
#box {
background: red;
border-radius: 50% 50% 50% 50%;
color: #FFFFFF;
height: 50px;
text-align: center;
width: 50px;
line-height: 50px;
vertical-align:middle;
}