DIV 讓數字水平垂直置中?
代言
代言 2017-02-24 14:52:44
0
2
811
.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; }

12

這樣設定的時候,數字都會中間偏下,沒辦法完全中間。請問該怎麼讓他完全水平垂直置中?


代言
代言

reply all (2)
phpcn_u933

只要添加: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; }


      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!