search

Home  >  Q&A  >  body text

css - label文字居中

label文字居中

.Botton {
    background-color: white;
    margin-left: 0.63rem;
    border-radius: 0.36rem;
    font-size: 1.6rem;
    height:2rem;
    width:1.5rem;
    display: -webkit-inline-box;
    font-weight: 300;
    text-align:center;
}
<label class="Botton">1</label>

没有居中是什么原因,不想通过设置padding

伊谢尔伦伊谢尔伦2779 days ago856

reply all(6)I'll reply

  • 怪我咯

    怪我咯2017-04-17 11:59:23

    Why the botton tag? Isn’t it a button

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:59:23

    Centered left and right: text-align:center;
    Centered top and bottom: line-height:2rem;

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:59:23

    For interline elements, you need to write inline-block

    In fact, it is recommended that you pad left and right

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:59:23

    text-align:center;display:inline-block;

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:59:23

    The inline block you use will adapt to the content, and there is no way to control the position of the content inside the block

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:59:23

    What is label? Please pay attention to label semantics

    reply
    0
  • Cancelreply