Html
    Css
    Js
a {
	font-size:2.5rem;
	margin:1rem;
	position:relative;
	color:darkslategray;
}
a:link {
	text-decoration:none;
}
a:after {
	content:"";
	position:absolute;
	bottom:-0.5rem;
	height:0.18rem;
	width:0%;
	transition:all 0.3s;
	left:0;
	background-color:blueviolet;
}
a:before {
	content:"";
	position:absolute;
	bottom:-0.5rem;
	height:0.18rem;
	width:0%;
	transition:all 0.3s;
	left:50%;
	background-color:#fff;
}
a:hover:after {
	animation-name:example;
	animation-duration:0.3s;
	animation-fill-mode:both;
}
a:hover:before {
	width:100%;
	left:0%;
	background-color:blueviolet;
}
@keyframes example {
	from {
	width:0%;
}
to {
	width:100%;
}
}

                        
↑上面代码改变,会自动显示代码结果 jQuery调用版本:2.1.4
 立即下载

css鼠标经过动画代码

更新时间:2021-07-01 02:06:43

鼠标进入时执行after动画,从左到右,并停留到最后一贞,执行before动画从中间开始并且从底色(#fff)到实际色,这样看起来像是只执行了after的动画;鼠标退出时只执行before动画,完成从中间隐藏

0