思路:
Q1:为什么下划线不用边框border 而使用背景色呢?
要实现动画效果,随着行盒的方向走
新知识点
线性渐变:linear-gradient
方法:linear-gradient(direction, color-stop1, color-stop2, ...)
详情见:https://blog.csdn.net/Bekind2010/article/details/130269260
Code
<!-- 新知识点:linear-gradient线性渐变 -->
<!-- Q1:为什么下划线不用边框border ;使用背景色呢? 要实现动画效果,随着行盒的方向走-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>下划线</title>
<style>
.title span {
background: linear-gradient(to right, #ff5f57, #45b6eb) no-repeat right bottom;
background-size: 0px 2px;
transition: background-size 1s;
}
.title span:hover {
background: linear-gradient(to right, #ff5f57, #45b6eb) no-repeat left bottom;
background-size: 100% 2px;
}
</style>
</head>
<body>
<h2 class="title">
<span>
党的路线、方针、政策“飞入寻常百姓家”
</span>
</h2>
</body>
</html>