How can I make to make the underline shorter, like in the photo.
And also hot to put a bit of space between the underline and Markets. Here's my code:
#a1:hover {
color: #55e691;
text-decoration: underline;
}
How can I make to make the underline shorter, like in the photo.
And also hot to put a bit of space between the underline and Markets. Here's my code:
#a1:hover {
color: #55e691;
text-decoration: underline;
}
#a1 {
display: inline-block;
color: rgb(31, 31, 31);
font-size: 20px;
font-weight: 700;
text-decoration: none;
}
#a1,
#a1 div {
-webkit-transition: .5s all;
transition: .5s all;
}
#a1:hover {
text-decoration: none;
color: #55e691;
}
#a1:hover div {
width: 70%;
height: 3px;
background-color: #55e691;
margin: 0 auto;
}
<a id="a1" href="">Markets
<div></div>
</a>
If you can add som HTML you can enclose a
tag in a <div>
. There's more than one way
#a1,
.shorter-underline div {
color: rgb(31, 31, 31);
text-decoration: none;
}
#a1,
.shorter-underline div {
-webkit-transition: .5s all;
transition: .5s all;
}
.shorter-underline {
display: inline-block;
font-size: 20px;
font-weight: 700;
}
#a1:hover {
text-decoration: none;
color: #55e691;
}
.shorter-underline:hover div {
width: 80%;
height: 3px;
background-color: #55e691;
margin: 0 auto;
}
<div class="shorter-underline">
<a id="a1" href="">Markets</a>
<div></div>
</div>
a {
font-weight: 300;
display: inline-block;
padding-bottom: 5px;
position: relative;
font-weight: bolder;
}
a:hover::after{
content: "";
position: absolute;
width: 50%;
height: 1px;
bottom: 0;
left: 25%;
border-bottom: 1px solid red;
}
<a>Markets</a>