鼠标移动到文字上出现下划线,并且下划线有动画效果

最近看到一个比较有意思的效果,就是鼠标移入后,在对应的文字下方会出现下划线的动画效果,当鼠标移除后,下划线动画会消失

下面线下划线的颜色我用的渐变写的,我想告诉大家的是他是一个背景

如下图:

 代码如下:

<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div class="box">
	<div class="box_cen">
		<div class="box_img">
			<img src="./images/1.jpg" alt="">
		</div>
		<div class="box_text">
			<span>Weighing the Trade-Offs of Native vs. Cross-Platform</span>
			<div>From an engineering standpoint, there are several options for building mobile applications, each with its strengths and weaknesses.</div>
			<div>Weighing the Trade-Offs of Native vs. Cross-Platform </div>
		</div>
	</div>
</body>
<style>
*{
	margin: 0;
	padding: 0;
}
img{
	width: 100%;
	height: 100%;
}
.box{
	width: 100%;
	height: auto;
	
}
.box_cen{
	width: 920px;
	height: 113px;
	border: 1px solid #ccc;
	margin-left: 300px;
	margin-top: 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.box_img{
	width: 150px;
	height: 95px;
	background-color: pink;
}
.box_text{
	width: 750px;
	height: 100%;
	font-size: 15px;
	color: #0099FF;
	margin-top: 5px;
	
}
.box_text span{
	font-size: 26px;
	background: linear-gradient(to right, red, pink) no-repeat right bottom;
	background-size: 0 3px;
	transition: background-size 2.5s;
	padding: 0 0 4px 0;
}
 .box_text span:hover{
	padding: 0 0 4px 0;
	font-size: 26px;
	background-position-x: left;
	background-size: 100% 3px ;
}
</style>
</html>

 鼠标移入那个标签需要使用span,我试了好几个标签出现的效果都有问题,只有span效果没问题

 以上就是鼠标移动到文字上出现下划线,并且下划线有动画效果的所有内容,感谢观看

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值