CSS Text underlining too long when letter-spacing is applied?

前端 未结 7 1202
别那么骄傲
别那么骄傲 2020-11-29 11:00


Whenever letter-spacing is applied to something with an underline or a bottom border, it seems like the underline extends beyond the text on the right. Is

7条回答
  •  难免孤独
    2020-11-29 12:05

    You can also use an absolute positioned pseudo element to achieve the underline, and counter the offset by specifying its with using the left and right property. Click below for an example.

    My underlined text
    
    span:after {
        content: '';
        border-bottom:1px solid #000;
        display: block;
        position: absolute;
        right: 5px;
        left: 0;
    }
    

    https://codepen.io/orangehaze/pen/opdMoO

提交回复
热议问题