Is there a way to create a hover effect where a border appears at the bottom of an element when it is being hovered over, and then retracts back when the mouse leaves the element? I've managed to get the border to appear on hover using CSS, but I'm struggling with making it retract smoothly. Here's a link to my Codepen for reference.
Here's the HTML:
<div class="object">
<p>Object</p>
</div>
And here's the CSS:
* {
background-color: #222;
color: white;
font-family: sans-serif;
font-size: 30pt;
}
p {
width: 200px;
height: 100%;
margin-top: 70px;
text-align: center;
transition: 0.2s border-bottom;
-webkit-transition: 0.2s border-bottom;
margin: auto;
margin-top: 50px;
}
p:hover {
border-bottom: 5px solid white;
}
If anyone could provide a simple solution to achieve the desired effect, that would be much appreciated! Thank you :)