I am using text-overflow: ellipsis
to clip text that is inside of a span that is inside of an anchor. The ellipsis character is not underlined when I hover which causes a small gap. Is there a way to fix this?
Yes, you can do this - set text-decoration: none
and instead of that use border-bottom
- DEMO
a {
display: block;
width: 185px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-decoration: none;
border-bottom: 1px solid transparent;
}
a:hover {
border-bottom: 1px solid #000;
}
If some one find this, like me, and do not like the fact that the border-bottom line is too far away this code might help DEMO
a {
display: block;
width: 185px;
background: beige;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-decoration: none;
color: #000;
position: relative;
}
a:hover::before {
content: '';
position: absolute;
bottom: 2px;
right: 0;
left: 0;
border-bottom: 1px solid black;
}
Still a hack, but you know... :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With