100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > html中背景条纹效果 css3 条纹背景滚动效果

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

时间:2021-07-25 16:58:20

相关推荐

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

今天在一个网站上看到这样一个效果,我一开始以为一个背景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;}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。