先上效果:(录制图片的效果有点卡顿,可以复制代码到html本地运行,效果更清晰)
代码如下:(ps:直接复制全部代码,到本地的html文件里,运行即可看到效果)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>鼠标移入下划线展开</title>
<style type="text/css">
.underline{
width: 200px;
height: 50px;
background: red;
margin: 20px;
position: relative;
}
.underline:after{
content: "";
width: 0;
height: 5px;
background: blue;
position: absolute;
top: 100%;
left: 50%;
transition: all .8s;
}
.underline:hover:after{
left: 0%;
width: 100%;
}
</style>
</head>
<body>
<div class="underline"></div>
</body>
</html>
欢迎大家提出自己的看法,共同进步