.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号
DIV 让数字水平垂直居中?-PHP中文网问答-DIV 让数字水平垂直居中?-PHP中文网问答
围观一下哦,学习一下。
不用这么麻烦
单行文字
将行高 line-height 和 height 设为相等即可
多行文字
需要将文字抱在p标签中
外层div display:table 内层p display:table-cell