gpt4 book ai didi

javascript - 悬停时导航栏下方的线

转载 作者:行者123 更新时间:2023-11-29 17:55:28 24 4
gpt4 key购买 nike

我搜索了很多关于这个但找不到,我怎么能在这里制作类似于导航栏的东西,当你将鼠标悬停在它上面时,它下面的一条线会看起来像一个加载栏。- 示例:http://www.thecrewgaming.com/是否可能只需要 css 或 javascript 以及如何?谢谢!

我试过了

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;
}

但它显示为一条普通线,不像上面链接的页面中的加载栏。

最佳答案

这很简单。

您在 ::after 伪选择器上使用了 position:absolute; 属性。

请参阅下面的 fiddle 和代码:

https://jsfiddle.net/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>

关于javascript - 悬停时导航栏下方的线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39495493/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com