css3 背景色 实现边框渐变运动动画

css3

            #body_id {
                animation: myfirst 10s ease-in-out -2s infinite alternate;
                /* Firefox: */
                -moz-animation: myfirst 10s ease-in-out -2s infinite alternate;
                /* Safari 和 Chrome: */
                -webkit-animation: myfirst 10s ease-in-out -2s infinite alternate;
                /* Opera: */
                -o-animation: myfirst 10s ease-in-out -2s infinite alternate;
                height: 51px;
            }

            .mui-bar {
                -webkit-box-shadow: none;
                box-shadow: none;
                background: #FFFFFF;
                height: 50px;
            }

            @keyframes myfirst {
                0% {
                    background: -moz-linear-gradient(left, red, #f96, yellow, green, #ace);
                    background: -webkit-linear-gradient(left, red, #f96, yellow, green, #ace);
                    background: -o-linear-gradient(left, red, #f96, yellow, green, #ace);
                    background: linear-gradient(left, red, #f96, yellow, green, #ace);
                }
                25% {
                    background: -moz-linear-gradient(left, #ace, red, #f96, yellow, green);
                    background: -webkit-linear-gradient(left, #ace, red, #f96, yellow, green);
                    background: -o-linear-gradient(left, #ace, red, #f96, yellow, green);
                    background: linear-gradient(left, #ace, red, #f96, yellow, green);
                }
                50% {
                    background: -moz-linear-gradient(left, green, #ace, red, #f96, yellow);
                    background: -webkit-linear-gradient(left, green, #ace, red, #f96, yellow);
                    background: -o-linear-gradient(left, green, #ace, red, #f96, yellow);
                    background: linear-gradient(left, green, #ace, red, #f96, yellow);
                }
                75% {
                    background: -moz-linear-gradient(left, yellow, green, #ace, red, #f96);
                    background: -webkit-linear-gradient(left, yellow, green, #ace, red, #f96);
                    background: -o-linear-gradient(left, yellow, green, #ace, red, #f96);
                    background: linear-gradient(left, yellow, green, #ace, red, #f96);
                }
                100% {
                    background: -moz-linear-gradient(left, #f96, yellow, green, #ace, red);
                    background: -webkit-linear-gradient(left, #f96, yellow, green, #ace, red);
                    background: -o-linear-gradient(left, #f96, yellow, green, #ace, red);
                    background: linear-gradient(left, #f96, yellow, green, #ace, red);
                }
            }

            @-moz-keyframes myfirst
            /* Firefox */

            {
                0% {
                    background: -moz-linear-gradient(left, red, #f96, yellow, green, #ace);
                }
                25% {
                    background: -moz-linear-gradient(left, #ace, red, #f96, yellow, green);
                }
                50% {
                    background: -moz-linear-gradient(left, green, #ace, red, #f96, yellow);
                }
                75% {
                    background: -moz-linear-gradient(left, yellow, green, #ace, red, #f96);
                }
                100% {
                    background: -moz-linear-gradient(left, #f96, yellow, green, #ace, red);
                }
            }

            @-webkit-keyframes myfirst
            /* Safari 和 Chrome */

            {
                0% {
                    background: -webkit-linear-gradient(left, red, #f96, yellow, green, #ace);
                }
                25% {
                    background: -webkit-linear-gradient(left, #ace, red, #f96, yellow, green);
                }
                50% {
                    background: -webkit-linear-gradient(left, green, #ace, red, #f96, yellow);
                }
                75% {
                    background: -webkit-linear-gradient(left, yellow, green, #ace, red, #f96);
                }
                100% {
                    background: -webkit-linear-gradient(left, #f96, yellow, green, #ace, red);
                }
            }

            @-o-keyframes myfirst
            /* Opera */

            {
                0% {
                    background: -o-linear-gradient(left, red, #f96, yellow, green, #ace);
                }
                25% {
                    background: -o-linear-gradient(left, #ace, red, #f96, yellow, green);
                }
                50% {
                    background: -o-linear-gradient(left, green, #ace, red, #f96, yellow);
                }
                75% {
                    background: -o-linear-gradient(left, yellow, green, #ace, red, #f96);
                }
                100% {
                    background: -o-linear-gradient(left, #f96, yellow, green, #ace, red);
                }
            }

html

        <div id="body_id" class="mui-bar mui-bar-tab">
            <nav class="mui-bar mui-bar-tab">
                <a id="defaultTab" class="mui-tab-item mui-active" href="home/home.html">
                    <span class="mui-icon "><img src="images/index/[email protected]" id="home/home.html"></span>
                    <span class="mui-tab-label">首页</span>
                </a>
                <a class="mui-tab-item" href="found/found.html">
                    <span class="mui-icon "><img src="images/index/[email protected]" id="found/found.html"></span>
                    <span class="mui-tab-label">发现</span>
                </a>
                <a class="mui-tab-item" href="release/release.html">
                    <span class="mui-icon "><img src="images/index/[email protected]" id="release/release.html"></span>
                    <span class="mui-tab-label">发布</span>
                </a>
                <a class="mui-tab-item" href="message/message.html">
                    <span class="mui-icon "><img src="images/index/mes[email protected]" id="message/message.html"><span class="mui-badge">9</span></span>
                    <span class="mui-tab-label">消息</span>
                </a>
                <a class="mui-tab-item" href="me/me.html">
                    <span class="mui-icon "><img src="images/index/[email protected]" id="me/me.html"/></span>
                    <span class="mui-tab-label">个人中心</span>
                </a>
            </nav>
        </div>

当然也可以这么写,运动更流畅

            #body_id {
                background: -moz-linear-gradient(left, red, #f96, yellow, green, #ace, red, #f96, yellow, green, #ace);
                background: -webkit-linear-gradient(left, red, #f96, yellow, green, #ace, red, #f96, yellow, green, #ace);
                background: -o-linear-gradient(left, red, #f96, yellow, green, #ace, red, #f96, yellow, green, #ace);
                background: linear-gradient(left, red, #f96, yellow, green, #ace, red, #f96, yellow, green, #ace);
                animation: myfirst 10s ease-in-out -2s infinite alternate;
                /* Firefox: */
                -moz-animation: myfirst 10s ease-in-out -2s infinite alternate;
                /* Safari 和 Chrome: */
                -webkit-animation: myfirst 10s ease-in-out -2s infinite alternate;
                /* Opera: */
                -o-animation: myfirst 10s ease-in-out -2s infinite alternate;
                height: 51px;
                width: 150%;
                overflow: hidden;
            }

            .mui-bar {
                -webkit-box-shadow: none;
                box-shadow: none;
                background: #FFFFFF;
                height: 50px;
            }

            @keyframes myfirst {
                0% {
                    bottom:0 ;left: -50%;
                }
                25% {
                    bottom:0 ;left: 0%;
                }
                50% {
                    bottom:0 ;left: -50%;
                }
                75% {
                    bottom:0 ;left: 0%;
                }
                100% {
                    bottom:0 ;left: -50%;
                }
            }

            @-moz-keyframes myfirst
            /* Firefox */
            {
                0% {
                    bottom:0 ;left: -50%;
                }
                25% {
                    bottom:0 ;left: 0%;
                }
                50% {
                    bottom:0 ;left: -50%;
                }
                75% {
                    bottom:0 ;left: 0%;
                }
                100% {
                    bottom:0 ;left: -50%;
                }
            }

            @-webkit-keyframes myfirst
            /* Safari 和 Chrome */
            {
                0% {
                    bottom:0 ;left: -50%;
                }
                25% {
                    bottom:0 ;left: 0%;
                }
                50% {
                    bottom:0 ;left: -50%;
                }
                75% {
                    bottom:0 ;left: 0%;
                }
                100% {
                    bottom:0 ;left: -50%;
                }
            }

            @-o-keyframes myfirst
            /* Opera */
            {
                0% {
                    bottom:0 ;left: -50%;
                }
                25% {
                    bottom:0 ;left: 0%;
                }
                50% {
                    bottom:0 ;left: -50%;
                }
                75% {
                    bottom:0 ;left: 0%;
                }
                100% {
                    bottom:0 ;left: -50%;
                }
            }
时间: 2024-09-30 11:52:26

css3 背景色 实现边框渐变运动动画的相关文章

CSS3与页面布局学习总结(六)——CSS3新特性(阴影、动画、渐变、变形、伪元素等)

目录 一.阴影 1.1.文字阴影 1.2.盒子阴影 二.背景 2.1.背景图像尺寸 2.2.背景图像显示的原点 三.伪元素 3.1.before 3.2.after 3.3.清除浮动 四.圆角与边框 4.1.border-radius 圆角 4.2.边框图片border-image 五.变形 transform 5.1.rotate()2D旋转 5.2.设置原点 transform-origin 5.3.平移 translate() 5.4.缩放 scale 5.5.斜切扭曲skew 六.渐变

CSS3新特性(阴影、动画、渐变、变形、伪元素等) CSS3与页面布局学习总结——CSS3新特性(阴影、动画、渐变、变形、伪元素等)

目录 一.阴影 1.1.文字阴影 1.2.盒子阴影 二.背景 2.1.背景图像尺寸 2.2.背景图像显示的原点 三.伪元素 3.1.before 3.2.after 3.3.清除浮动 四.圆角与边框 4.1.border-radius 圆角 4.2.边框图片border-image 五.变形 transform 5.1.rotate()2D旋转 5.2.设置原点 transform-origin 5.3.平移 translate() 5.4.缩放 scale 5.5.斜切扭曲skew 六.渐变

CSS3(六 CSS3新特性(阴影、动画、渐变、变形、伪元素等)

目录 一.阴影 1.1.文字阴影 1.2.盒子阴影 二.背景 2.1.背景图像尺寸 2.2.背景图像显示的原点 三.伪元素 3.1.before 3.2.after 3.3.清除浮动 四.圆角与边框 4.1.border-radius 圆角 4.2.边框图片border-image 五.变形 transform 5.1.rotate()2D旋转 5.2.设置原点 transform-origin 5.3.平移 translate() 5.4.缩放 scale 5.5.斜切扭曲skew 六.渐变

js运动动画

今天简单的学了一下js运动动画,再此感谢慕课网的这位老师http://www.imooc.com/view/167,讲的很不错. 下面是我整理出来的结果. 知识点一:速度动画. 1.首先第一步实现速度运动动画,封装一个函数,用到的知识是setInterval(function(){ oDiv.style.left=oDiv.offsetLeft+10+"px"; },30). 对于这里为什么要用到offsetLeft,我特意百度了一下,http://www.cnblogs.com/wo

CSS3伪类nth-child结合transiton动画实现文字若影若现

css3伪类nth-child结合transiton动画实现文字若影若现收先创建一个div盒子,然后包裹在div中的有10个span标签每个span标签填上内容一次为A,B,C,D,E,F,G,H,I,,J先看下效果图: 看HTML5代码: <div class="box"> <span>A</span> <span>B</span> <span>C</span> <span>D</s

一款纯css3实现的颜色渐变按钮

之前为大家分享了推荐10款纯css3实现的实用按钮,今天给大家带来一款纯css3实现的颜色渐变按钮.这款按钮的边框和文字的颜色通过css3实现两种颜色的渐变,效果非常好看,一起看下效果图: 在线预览   源码下载 实现的代码. html代码: <div class="container"> <a target="_blank" class="btn green" href="http://www.w2bc.com/&q

css3中的transition渐变过渡属性的认识.

css3新增的属性transition可以让元素产生动画效果: 用法(兼容代码): -webkit-transition:property(属性样式) duration(过渡时间) timing-function过渡模式(5种过渡模式效果) -moz-transition:property(属性样式) duration(过渡时间) timing-function过渡模式(5种过渡模式效果) -o-transition:property(属性样式) duration(过渡时间) timing-fu

使用CSS3创建文字颜色渐变(CSS3 Text Gradient)

考虑一下,如何在网页中达到类似以下文字渐变的效果? 传统的实现中,是用一副透明渐变的图片覆盖在文字上.具体实现方式可参考 http://www.qianduan.net/css-gradient-text-effect.html .这种方式优点是图片可控,所以可实现很复杂的渐变效果,但是缺点是图片渐变色必须与背景色一致,同时损失了鼠标点击.文字选择等事件. 改进的方法可以使用 CSS3 的背景渐变 -webkit-gradient ,用一个背景渐变的 DIV 代替图片.下面是实现效果示例,相比以

css边框渐变

在实际开发中,我们经常遇见边框需要背景渐变的实现要求,那么如何去实现呢,今天给大家分享依稀几种情况 1.直角的背景渐变 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0&q