Edit line thickness of CSS 'underline' attribute

前端 未结 11 668
日久生厌
日久生厌 2020-12-02 07:35

Since you can underline any text in CSS like so:

h4 {
    text-decoration: underline;
}

How can you also then edit the \'line\' that is drawn

11条回答
  •  不知归路
    2020-12-02 08:20

    Another way to do this is using ":after" (pseudo-element) on the element you want to underline.

    h2{
      position:relative;
      display:inline-block;
      font-weight:700;
      font-family:arial,sans-serif;
      text-transform:uppercase;
      font-size:3em;
    }
    h2:after{
      content:"";
      position:absolute;
      left:0;
      bottom:0;
      right:0;
      margin:auto;
      background:#000;
      height:1px;
    
    }
    

提交回复
热议问题