html中背景条纹效果,css3 条纹背景滚动效果

a9f1fd14994d69d985bca1a50d9e733f.gif

今天在一个网站上看到这样一个效果,我一开始以为一个背景gif图片,为了验证我的想法,我打开firebug 一查看,原来不是gif。是用css3完成的。于是我就在查看css3的api帮助下尝试着 写一写,代码如下

html代码很简单 就一个div就ok,只不过在样式里面 加了一个 :after。

下面直接上css代码:

.test{margin: 100px auto; width: 250px;height: 60px; background-color: #666;position: relative;}

.test:after{ position: absolute;top: 0;left: 0;width: 100%;height: 100%;content: "";

background: -webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));

background: -webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));

background: -webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);

background: -moz-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);

background: -o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);

background: linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);

-webkit-animation: twb-bar 2s linear infinite;

-moz-animation: twb-bar 2s linear infinite;

-ms-animation: twb-bar 2s linear infinite;

-o-animation: twb-bar 2s linear infinite;

animation: twb-bar 2s linear infinite;

-webkit-background-size: 40px 40px;

-moz-background-size: 40px 40px;

-o-background-size: 40px 40px;

background-size: 40px 40px;

}

@-webkit-keyframes twb-bar {

from {background-position: 40px 0;}

to { background-position: 0 0; }

}

@-moz-keyframes twb-bar {

from { background-position: 40px 0;}

to {background-position: 0 0;}

}

@-ms-keyframes twb-bar {

from {background-position: 40px 0;}

to { background-position: 0 0;}

}

@-o-keyframes twb-bar {

from {background-position: 0 0;}

to { background-position: 40px 0;}

}

@keyframes twb-bar {

from { background-position: 40px 0;}

to { background-position: 0 0;}

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值