I searched alot about this and couldn't find , how can I make something similar to the navbar here , when you hover on it a line under it will appear like a loading bar . - example : / is it possible only with css or javascript is needed and how ? thanks !
I tried this
li:hover {
background-color: rgba(255, 245, 255, 0.2);
border-bottom-color: #abcdef;
}
li {
font-family: 'Poppins', sans-serif;
font-weight: bold;
color: #F5F5F5;
font-size: 0.8889em;
text-decoration: none;
font-weight: normal;
text-transform: uppercase;
border-bottom: 3px solid transparent;
padding-bottom: 0.125em;``
transition: border-bottom-color 50ms linear 0s;
}
but it appears as a normal line and not like a loading bar in the page linked above .
I searched alot about this and couldn't find , how can I make something similar to the navbar here , when you hover on it a line under it will appear like a loading bar . - example : http://www.thecrewgaming./ is it possible only with css or javascript is needed and how ? thanks !
I tried this
li:hover {
background-color: rgba(255, 245, 255, 0.2);
border-bottom-color: #abcdef;
}
li {
font-family: 'Poppins', sans-serif;
font-weight: bold;
color: #F5F5F5;
font-size: 0.8889em;
text-decoration: none;
font-weight: normal;
text-transform: uppercase;
border-bottom: 3px solid transparent;
padding-bottom: 0.125em;``
transition: border-bottom-color 50ms linear 0s;
}
but it appears as a normal line and not like a loading bar in the page linked above .
Share Improve this question edited Sep 14, 2016 at 16:36 Abhishek Pandey 13.6k8 gold badges40 silver badges72 bronze badges asked Sep 14, 2016 at 16:30 Mehdi LoukiliMehdi Loukili 312 silver badges6 bronze badges 2- Hi Mehdi - have a look at the answers below and either mark an answer as accepted, or provide us some sort of feedback so that we may help you further! – Frits Commented Sep 14, 2016 at 18:32
- @Frits Already marked , question solved ! – Mehdi Loukili Commented Sep 14, 2016 at 18:42
2 Answers
Reset to default 3It's quite simple.
You use a position:absolute;
property on a ::after
pseudo selector.
See the fiddle and the code below:
https://jsfiddle/cuv6bxs5/
li {
font-family: 'Poppins', sans-serif;
font-weight: bold;
color: red;
background-color: #404040;
float: left;
position: relative;
padding: 10px 20px;
overflow: hidden;
}
li::after {
background-color: red;
content: "";
width: 0;
height: 3px;
left: 0;
bottom: 0;
transition: width 0.35s ease 0s;
position: absolute;
}
li:hover::after {
width: 100%;
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
<ul>
<li>ONE</li>
<li>TWO</li>
<li>THREE</li>
<li>FOUR</li>
</ul>
There are several ways to do this.
They did it using the :after
pseudo selector with transition
for the animation.
header .menu_links a {
display: inline-block;
font-weight: 600;
font-size: 14px;
height: 50px;
color: #fff;
text-transform: uppercase;
padding-left: 20px;
padding-right: 20px;
overflow-x: hidden;
position: relative;
transition: .25s ease all;
background: gray;
text-decoration: none;
line-height: 45px;
}
header .menu_links a:after {
content: " ";
position: absolute;
display: block;
bottom: 0;
left: -100%;
height: 5px;
width: 100%;
background: #dd0034;
transition: .5s ease all;
}
header .menu_links a:hover:after {
left: 0;
}
<header>
<div class="menu_links">
<a href="#">Link A</a>
<a href="#">Link B</a>
</div>
</header>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745482163a4629605.html
评论列表(0条)