css - DIV 讓數字水平垂直置中?
本文介绍了css - DIV 讓數字水平垂直置中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
.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>
這樣設定的時候,數字都會中間偏下,沒辦法完全中間。
請問該怎麼讓他完全水平垂直置中?
解决方案
.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;
}
这篇关于css - DIV 讓數字水平垂直置中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文