.unsolve
{
position: absolute;
right: 10px;
top:50%;
transform: translate(0,-50%);
z-index: 1;
font-size: 13px;
background-color: red;
border-radius: 50%;
color:#fff;
width: 15px;
height: 15px;
padding: 5px;
text-align: center;
}<div class="unsolve">12</div>
這樣設定的時候,數字都會中間偏下,沒辦法完全中間。請問該怎麼讓他完全水平垂直置中?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
只要添加:line-height : (div高度)px
就可以文字居中了
.unsolve { position: absolute; right: 10px; top:0; bottom: 0; margin:auto; z-index: 1; font-size: 13px; background-color: red; border-radius: 50%; color:#fff; width: 15px; height: 15px; line-height: 15px; padding:5px; text-align: center; }