文章来源地址https://www.toymoban.com/news/detail-818544.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>css下划线跟随导航</title>
<style>
*{
margin: 0;
padding: 0;
}
ul{
list-style: none;
display: flex;
}
ul>li{
cursor: pointer;
padding: 20px;
line-height: 1.5;
font-size: 20px;
position: relative;
}
li::before{
content: "";
position: absolute;
top: 0;
left: 100%;
border-bottom: 2px solid red;
width: 0;
height: 100%;
transition: 0.3s all linear;
z-index: -1;
/* background-color: skyblue; */
}
li:hover::before{
width: 100%;
left: 0;
top: 0;
}
/* 下划线跟随效果*/
li:hover~li::before{
left: 0;
width: 0;
}
</style>
</head>
<body>
<ul>
<li>首页</li>
<li>热门</li>
<li>推荐</li>
<li>视频</li>
<li>音乐</li>
<li>个人中心</li>
</ul>
</body>
</html>
文章来源:https://www.toymoban.com/news/detail-818544.html
到了这里,关于css下划线跟随导航的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!