CSS decrease space between text and border

后端 未结 5 1634
再見小時候
再見小時候 2021-02-05 19:35

When hovering a link I want it to get an underline. The underline should be 2px strong and 4px below the text.

With

text-decoration: underline

5条回答
  •  忘掉有多难
    2021-02-05 19:52

    You can use background with linear-gradient to produce a border, and with it you can position it anywhere.

    For example:

    background-image: linear-gradient(currentColor, currentColor);
    background-position: 0 95%; /* determines how far from bottom */
    background-repeat: no-repeat;
    background-size: 100% 5px; /* second value determines height of border */
    

    http://jsfiddle.net/1mg4tkwx/

    Credit: https://www.dannyguo.com/blog/animated-multiline-link-underlines-with-css/

提交回复
热议问题