How to ensure that thick underline works on line breaks?
P粉366946380
P粉366946380 2023-09-05 13:21:47
0
1
473
<p>I'm using the following code to add a thicker/more stylized underline decoration to my hyperlinks. </p> <pre class="brush:php;toolbar:false;">a { text-decoration: none; position: relative;} a:hover { color: #c0632e; } a::after { content: ""; position: absolute; width: 100%; height: 30%; bottom: 0; left: 0; background-color: #2EB0C0; opacity: 0.15; z-index: -1; } a:hover::after { background-color: #c0632e; }</pre> <p>However, it only works if I convert it to a class and add it to each link as <code><span></code>. If I try to implement it globally, it doesn't work when there is a newline in the middle of the hyperlink. It works fine when there are no line breaks, but not when there are line breaks. </p> <p>Is there a way to fix this so that it can be used globally without having to define <code><span></code> for each hyperlink? </p>
P粉366946380
P粉366946380

reply all(1)
P粉356128676

I also encountered the same problem recently. I suggest you use border bottom instead of ::after. Try this:

a {
    border-bottom: 1rem solid;
}

You can also use px to specify the size instead of rem. Don't forget to specify the border color if it doesn't show up

border-color: black;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template