console
$(function(){
$("a").click(function(){
$("a").removeClass("red")
$(this).addClass("red")
})
})
<a href="javascript:void(0)">测试1</a>
<a href="javascript:void(0)">测试2</a>
<a href="javascript:void(0)">测试3</a>
<a href="javascript:void(0)">测试4</a>
<a href="javascript:void(0)">测试5</a>
body{
background: black;
}
a{
color:#ffffff;
position: relative;
text-decoration: none;
font-size: 20px;
display: inline-block;
margin: 10px;
transition: all .3s;
}
.red{
color:red;
}
a.red:before{
width: 100%;
right: 0;
left: 0;
background: red;
}
a:before{
content:"";
position:absolute;
width: 0;
left: 50%;
right: 50%;
bottom: -2px;
height: 2px;
background: #fff;
transition: all .3s;
}
a:hover:before{
width: 100%;
right: 0;
left: 0;
}