按钮显示箭头过度动画transition

本文介绍了一种按钮上的文字和箭头动画过渡效果的实现方法。当鼠标悬停在按钮上时,文字会向左滑动,同时右侧箭头从右向左滑出;当鼠标离开时,文字和箭头会恢复原状。通过CSS样式和过渡属性完成这一动画效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

按钮效果在这里插入图片描述
当鼠标悬停按钮上时,文字向左滑动,并且在右侧箭头从右向左滑出在这里插入图片描述当鼠标再次离开按钮时,文字向右滑动回原位置,并且右侧滑出箭头向右隐藏
在这里插入图片描述

附上过渡效果代码

<head>
	    <meta charset="UTF-8">
	    <title>按钮显示箭头动画transition过度</title>
	    <style>
	        .button{
	            border:none;
	            background-color:red;
	            color:white;
	            padding:15px 20px;
	            font-size:15px;
	            cursor:pointer;
	            border-radius:5px;
	            width:150px;
	         }
	        .button span{
	           position: relative;
	           display: inline-block;
	           transition: .5s;
	         }
	       .button span::after{
	           content: "»";
	           opacity:0;
	           right:-20px;
	           position: absolute;
	           transition: .5s;
	         }
	       .button:hover span{
	           padding-right: 25px;
	        }
	       .button:hover span:after{
	           opacity: 1;
	           right: 0;
	        }
	    </style>
	</head>
	<body>
	    <button class="button"><span>我是按钮</span></button>
	</body>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值