自制背景渐变的button按钮—div css3代码展示

今天分享下”自制背景渐变的button按钮—div css3代码展示“这篇文章,文中根据实例编码详细介绍,或许对大家的编程之路有着一定的参考空间与使用价值,需要的朋友接下来跟着云南仟龙Mark一起学习一下吧

伴随着现阶段前面网页页面的需求量持续提高,有一些情景必须渐变背景的原素。文中利用div和css3新属性,完成了一个背景渐变的按键,实际以下:
1.background: linear-gradient 背景为渐变色属性
2.利用css3中动漫特性animation,完成背景从左至右转变 (color_move)
3.为了更好地完成渐变实际效果,将background的总宽变长至400%

上代码:

html:

<div class="btn_demo">
    <div class="text">体 验</div>
    <div class="arrow">»</div>
</div>

css:

@keyframes arrow_move {
/* 开始状态 /
0% {
left: 130px;
}
/
结束状态 /
100% {
left: 140px;
}
}
@keyframes color_move {
/
开始状态 /
0% {
background-position: 0% 0%; /
水平位置 垂直位置 /
}
50% {
background-position: 50% 0%;
}
/
结束状态 /
100% {
background-position: 100% 0%;
}
}
.btn_demo {
width:180px;
height:60px;
border-radius: 10px;
position: relative;
background: linear-gradient( 90deg, #373d42 0%, #2679dd 50%, #373d42 100%);
background-size: 400% 100%;
animation: color_move 5s infinite ease-in-out alternate;
cursor: pointer;
}
.btn_demo:hover {
background: #2679dd;
}
.btn_demo:active {
background: #373d42;
}
.btn_demo > .text {
/
background: yellow; /
width: 50px;
text-align: center;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
font-size: 20px( http://www.qlyl1688.com/products/yyxjjc5188.html );
color: #fff;
font-weight: bold;
}
.btn_demo > .arrow {
/
background: green; /
width: 20px;
text-align: center;
position: absolute;
font-size: 30px;
color: #fff;
top: 46%;
transform: translateY(-50%);
left: 130px; /
移动130~150px /
/
调用动画 /
animation-name: arrow_move;
/
持续时间 /
animation-duration: 1s;
/
无限播放 */
animation-iteration-count: infinite;
}

到此这篇关于自制背景渐变的button按钮—div css3代码展示的文章就介绍到这了,更多请关注脚本之家,下次见。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值