search

Home  >  Q&A  >  body text

Centering, the difference between height and line-height, define which attribute respectively

<h3 style="text-align: center;background: pink;height: 50px;line-height: 50px;">居中</h3>

</body>


刘春阳刘春阳2221 days ago1414

reply all(2)I'll reply

  • 灭绝师太

    灭绝师太2018-10-31 09:08:11

    height is to define the height of the element, and line-height is to define the line height (referring to the distance between text and baseline)

    reply
    0
  • 刘春阳

    The line-height effect is centered

    刘春阳 · 2018-10-31 09:26:31
    刘春阳

    If line height is not 25px centered

    刘春阳 · 2018-10-31 09:27:12
    灭绝师太

    It's not centered, but it can achieve the centering effect. Line-height defines the line height.

    灭绝师太 · 2018-10-31 11:14:39
  • Cancelreply