实现效果:

样式代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>鼠标移入下划线展开</title>
<style type="text/css">
#underline{
width: 200px;
height: 50px;
background: #ddd;
margin: 20px;
position: relative;
}
#underline:after{
content: "";
width: 0;
height: 1px;
background: blue;
position: absolute;
top: 100%;
left: 50%;
transition: all .8s;
}
#underline:hover:after{
left: 0%;
width: 100%;
}
</style>
</head>
<body>
<div id="underline"></div>
</body>
</html>

本文介绍了一个使用纯CSS实现的鼠标悬停下划线动画效果,通过`:hover`伪类和`transition`属性,使下划线在鼠标移入时平滑地从中间向两边扩展,为网站导航或按钮元素增添互动感。
2933

被折叠的 条评论
为什么被折叠?



