hover时下划线从中间向两端渐变

.nav{
	float: left;
}
.nav ul li {
	float: left;
	position: relative;
}
.nav ul li a{
	color: #FFF;
	font-size: 16px;
	line-height: 80px;
	margin: 0 25px;
}
.nav ul li:hover:before{
    left: 0;
    width: 100%;
    }
.nav ul li:before {
    content: "";
    width: 0;
    border-bottom: 2px solid #e5081c;
    position: absolute;
    bottom: 0;
    left: 50%;
    transition: all linear 0.3s;
}
.nav ul li:hover a{
	color: #e5081c;
}
.nav ul .active a{
	color: #e5081c;
}
.nav ul .active:before{
	left: 0;
    width: 100%;
}

  

			<div class="nav">
				<ul>
					<li class="active"><a href="#">首页</a></li>
					<li><a href="#">关于我们</a></li>
					<li><a href="#">产品中心</a></li>
					<li><a href="#">新闻资讯</a></li>
					<li><a href="#">联系我们</a></li>
				</ul>
			</div>

  

posted @ 2021-03-03 11:30  六人行  阅读(162)  评论(0编辑  收藏  举报