发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
关键帧(鼠标移上来)
过渡(鼠标移上来)
关键帧W3School教程导航
CSS样式设置:
1 /* 2 我这里的动画是鼠标移到DIV上面改变背景色、前景色和宽度 3 @keyframes=定义动画 4 aniName=动画名称 5 from{}=动画开始样式(可以省略开始样式) 6 to{}=动画结束样式 7 */ 8 @keyframes aniName { 9 /*动画开始CSS样式,开始样式可以省略*/ 10 from{ 11 /*这里面写CSS样式 例子:*/ 12 background-color:#f00; 13 color:#00f; 14 width:300px; 15 } 16 /*动画结束CSS样式*/ 17 to{ 18 /*这里面写CSS样式 例子:*/ 19 background:#00f; 20 color:#f00; 21 width:500px; 22 } 23 } 24 /*到这里动画已经定义好了,但是为了让更多浏览器支持,所以我们再添加下面代码*/ 25 26 /*解决火狐兼容等*/ 27 @-moz-keyframes aniName { 28 from{ 29 background-color:#f00; 30 color:#00f; 31 width:300px; 32 } 33 to{ 34 background:#00f; 35 color:#f00; 36 width:500px; 37 } 38 } 39 /*解决谷歌等浏览器兼容*/ 40 @-webkit-keyframes aniName { 41 from { 42 background-color: #f00; 43 color: #00f; 44 width: 300px; 45 } 46 to { 47 background: #00f; 48 color: #f00; 49 width: 500px; 50 } 51 } 52 /*解决Opera浏览器兼容*/ 53 @-o-keyframes aniName { 54 from { 55 background-color: #f00; 56 color: #00f; 57 width: 300px; 58 } 59 to { 60 background: #00f; 61 color: #f00; 62 width: 500px; 63 } 64 } 65 /* 66 到这里基本的兼容性就解决了,接下来就是使用 css代码:animation 67 我这里是给一个DIV添加动画 在html代码中添加一个div ID=testDIV_A 68 */ 69 #testDIV_A:hover { 70 -moz-animation: 1s alternate infinite aniName; 71 -o-animation: 1s alternate infinite aniName; 72 -webkit-animation: 1s alternate infinite aniName; 73 animation: 1s alternate infinite aniName; 74 }
到这里关键帧动画就完成了,接下来就是过渡动画
过渡简介:过渡是你改变对象的CSS样式时的一个动画W3School教程导航CSS样式:
1 /* 2 我这里的动画和上面一样,鼠标移到DIV上面改变背景色、前景色和宽度 3 这里还是一个DIV ID=testDIV_B 4 */ 5 #testDIV_B { 6 -moz-transition: width,background,color; 7 -o-transition: width,background,color; 8 -webkit-transition: width,background,color; 9 transition: width 1s,background 3s,color 2s; 10 } 11 #testDIV_B:hover{ 12 /* 13 由于宽度和背景色无法在这里改变,所以我写在JS里面了 14 <script> 15 $('#testDIV_B').mousemove(function () { 16 $(this).css({ 'background': '#0ff', 'width': '500px' }); 17 }); 18 $('#testDIV_B').mouseout(function () { 19 $(this).css({ 'background': '#f00','width':'100px' }); 20 }); 21 </script> 22 */ 23 color:#ff0; 24 }
到这里这次教程就结束了,更多的需要自己去发现,我这里只是把入门的东西写上了而已!
不是所有浏览器都支持
来自: 昵称10504424 > 《工作》
0条评论
发表
请遵守用户 评论公约
css3动画梳理
css3动画梳理。Css3动画 主要有3种:Transition、Transform 、Animation。width: 100px;height: 100px;height:200px;transition:height 1s ease-in 1s,width 1s ease-in 0s;margin-top: 200px;/*transf...
CSS动画实例:一颗躁动的心
在CSS样式的作用下,这2个层在浏览器中显示如图1所示,其中心心由三个部分构成:一个高度和宽度均为100px的正方形(由.heart样式规则决...
CSS层叠样式表笔记
outline 复合属性:设置或检索对象外的线条轮廓 outline-width 设置或检索对象外的线条轮廓的宽度 outline-style 设置或检索对象外的线条轮廓的样式 outli...
【聊代码】第五十五集 css样式(之二十五)十五种艺术字体代
CSS动画——行走的小人
padding : 100px 0 0 100px;}.hat { transform : translate(-12px, -10px) rotate(-10deg);}.ball { transform : translate(20px, -35px...
纯CSS3发光按钮动画 非常绚丽 – 码农网
}@-webkit-keyframes bigAssButtonPulse { from { background-color: #749a02;-webkit-box-shadow: 0 0 25px #333;-webkit-box-shadow: ...
飘逸洒脱的纯CSS3飞行菜单,三级下拉菜单
CSS动画实例:跳跃的字符
让等待变爽快!用CSS3创建预加载动画集
<div id="preloader_1"> <span></span> <span></span> <span></span>...
微信扫码,在手机上查看选中内容