I have an anchor tag, and I'm using the :before selector to add some text. I have added a hover state around the anchor tag. The :before
text is slightly larger than the rest of the text in the anchor tag and I'm adding a display: inline-block
property to the before text.
When I hover over the anchor tag, the hover state is wrapped tightly around the all the anchor text, including the :before
text (EXAMPLE 1 in codepen). Like so:
https://user-images.githubusercontent.com/20184809/52691191-27364e80-2fb4-11e9-9ffe-8777e645acee.png
How ever if I add the display:inline-block
property to the anchor tag the hover state is a rectangle which matches the height of the larger :before
text. Like so:
https://user-images.githubusercontent.com/20184809/52691272-7da38d00-2fb4-11e9-900b-c795623de3e2.png
Why is this?
.link-1:hover, .link-2:hover {
outline: 3px solid green;
outline-offset: 2px;
}
.link:before {
content:':before text';
font-size: 35px;
display: inline-block;
}
.link-1 {
display: inline-block;
}
<!-- EXAMPLE 2 -->
<a href="#" class="link link-2"> anchor text</a>
<br>
<!-- EXAMPLE 1 -->
<a href="#" class="link link-1"> anchor text</a>
EDIT:
I've noticed this happens on Chrome and not Safari and firefox. It could be a browser thing?