Maison  >  Questions et réponses  >  le corps du texte

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>

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

橱窗的光橱窗的光2792 Il y a quelques jours1127

répondre à tous(2)je répondrai

  • 数据分析师

    数据分析师2017-10-01 00:33:34

    DIV Centrer les chiffres horizontalement et verticalement ? -Site Web chinois PHP Q&A-DIV Centrer les nombres horizontalement et verticalement ? - Questions et réponses sur le site Web chinois PHP

    Veuillez regarder et apprendre.

    répondre
    0
  • 迷茫

    迷茫2017-02-27 09:31:06

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

    répondre
    0
  • Annulerrépondre