DIV 让数字水平垂直居中?
橱窗的光
橱窗的光 2017-02-27 09:26:12
0
2
1129
.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>

    这样设定的时候,数字都会中间偏下,沒办法完全居中。请问该怎么样让他完全水平垂直居中?

橱窗的光
橱窗的光

모든 응답(2)
数据分析师

DIV 숫자를 가로와 세로 가운데에 배치하시겠습니까? -PHP 중국어 웹사이트 Q&A-DIV 숫자를 가로와 세로로 가운데에 배치하나요? -PHP 중국어 홈페이지 Q&A

꼭 보고 배워보세요.

迷茫

不用这么麻烦
单行文字 
将行高 line-height 和 height 设为相等即可
多行文字
需要将文字抱在p标签中 
外层div display:table 内层p display:table-cell

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!