验证中...
8月18日(周六)成都源创会火热报名中,四位一线行业大牛与你面对面,探讨区块链技术热潮下的冷思考。
Snippet 1 Snippet 2
导航栏下划线跟随效果.html
Raw Copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>不可思议的纯CSS导航栏下划线跟随效果</title>
<style>
* {margin: 0;padding: 0;box-sizing: border-box;}
.nav {width: 100%;padding: 20px;position: relative;overflow: hidden;}
a{text-decoration: none;color: #000;}
.nav li {list-style: none;position: relative;float: left;width: 20%;text-align: center;
font-size: 18px;color: #000;line-height: 1;transition: 0.2s all linear;cursor: pointer;}
.nav li::before {content: "";position: absolute;top: 0;left: 100%;width: 0;
height: 100%;border-bottom: 2px solid #000;transition: 0.2s all linear;}
.nav li:hover::before {width: 100%;top: 0;left: 0;transition-delay: 0.1s;border-bottom-color: #000;}
/* 为所有相同的父元素中位于 li:hover 之后的所有li::before设置样式: */
.nav li:hover~ .nav li::before {left: 0;}
/* 点击的时候触发点击样式 */
.nav li:active {background: #000;color: #fff;}
</style>
</head>
<body>
<ul class="nav">
<li><a target="_blank" href="https://hjm100.cn/Blogs">Home</a></li>
<li><a target="_blank" href="https://gitee.com/hjm100">Gitee</a></li>
<li><a target="_blank" href="https://hjm100.cn/about">About</a></li>
<li><a target="_blank" href="https://github.com/hjm100">Github</a></li>
</ul>
</body>
</html>
效果展示.png

Comment list( 1 )

1329024_hjm100
鸿基梦 2018-04-08 12:09

demo浏览地址:http://hjm100.gitee.io/me

You need to Sign in for post a comment