CSS3学习笔记(1)-淡入的文字_html/css_WEB-ITnose
程序员文章站
2022-06-11 23:15:23
...
今天有空把前几天学的东西发一下,都是一些简单的东西,但是千里之行始于足下,我虽然走的慢,但是未停下前进的脚步~~~~~~~
下来看下我做的“淡入的文字”最终动态效果:
上面这个动画效果制作的过程是:
(1)先自定义一个透明度从0到1变化的动画,然后在animation中调用这个动画效果
(2)注意不同行文字出现的时间先后,这个通过animation中延时属性可以实现
(3)规定文字最终动态为动画的最终显示状态,否则文字显示完会自动消失,这个用animation-fill-mode可以实现
一、先来看看HTML中程序:
淡入的文字 山一程,水一程,身向榆关那畔行,夜深千帐灯。风一更,雪一更,聒碎乡心梦不成,故园无此声。
上面这段程序主要是先把文字呈现出来,我随便找了一首诗啦~~~~~大家不要去猜它的意思QAQ
二、看看CSS样式(主要是CSS3)
.fade-in-words{ width: 200px; margin: 0 auto; text-align: center;}/*自定义一个透明度从0到1的动画,它的名称是fade-in*/@keyframes fade-in{ 0%{ opacity: 0;} 100%{opacity:1;}}@-webkit-keyframes fade-in{ 0%{ opacity: 0;} 100%{opacity:1;}}@-ms-keyframes fade-in{ 0%{ opacity: 0;} 100%{opacity:1;}}@-o-keyframes fade-in{ 0%{ opacity: 0;} 100%{opacity:1;}}@-moz-keyframes fade-in{ 0%{ opacity: 0;} 100%{opacity:1;}}.first-words{ opacity: 0; /*实先规定文字的状态是不显示的*/ animation: fade-in 4s ease 0s 1; /*调用名称为fade-in的动画,全程动画显示时间4S,进入方式为ease,延时0S进入,播放次数1次*/ -webkit-animation: fade-in 4s ease 0s 1; -moz-animation: fade-in 4s ease 0s 1; -o-animation: fade-in 4s ease 0s 1; -ms-animation: fade-in 4s ease 0s 1; /*规定动画的最后状态为结束状态*/ animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; }.second-words{ opacity: 0; animation: fade-in 4s ease 2s 1; -webkit-animation: fade-in 4s ease 2s 1; -moz-animation: fade-in 4s ease 2s 1; -o-animation: fade-in 4s ease 2s 1; -ms-animation: fade-in 4s ease 2s 1; /*规定动画的最后状态为结束状态*/ animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; }.third-words{ opacity: 0; animation: fade-in 4s ease 4s 1; -webkit-animation: fade-in 4s ease 4s 1; -moz-animation: fade-in 4s ease 4s 1; -o-animation: fade-in 4s ease 4s 1; -ms-animation: fade-in 4s ease 4s 1; /*规定动画的最后状态为结束状态*/ animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; }.four-words{ opacity: 0; animation: fade-in 4s ease 6s 1; -webkit-animation: fade-in 4s ease 6s 1; -moz-animation: fade-in 4s ease 6s 1; -o-animation: fade-in 4s ease 6s 1; -ms-animation: fade-in 4s ease 6s 1; /*规定动画的最后状态为结束状态*/ animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; }.five-words{ opacity: 0; animation: fade-in 4s ease 8s 1; -webkit-animation: fade-in 4s ease 8s 1; -moz-animation: fade-in 4s ease 8s 1; -o-animation: fade-in 4s ease 8s 1; -ms-animation: fade-in 4s ease 8s 1; /*规定动画的最后状态为结束状态*/ animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; }.six-words{ opacity: 0; animation: fade-in 4s ease 10s 1; -webkit-animation: fade-in 4s ease 10s 1; -moz-animation: fade-in 4s ease 10s 1; -o-animation: fade-in 4s ease 10s 1; -ms-animation: fade-in 4s ease 10s 1; /*规定动画的最后状态为结束状态*/ animation-fill-mode:forwards; -webkit-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; }
上面的程序我在注释里面都写得很清楚,感兴趣的可以看我写的注释,我觉得比较简单,没有难度,但是需要注意浏览器前缀的添加,否则你懂得~~~~
上一篇: 这个地方怎么实现的?
推荐阅读
-
html5中canvas学习笔记1-画板的尺寸与实际显示尺寸
-
CSS3学习笔记(1)-淡入的文字_html/css_WEB-ITnose
-
css笔记--区分css3中的transform transition animation_html/css_WEB-ITnose
-
CSS3选择器之学习笔记_html/css_WEB-ITnose
-
CSS3学习笔记之border-radius_html/css_WEB-ITnose
-
web前端学习笔记-scrollWidth,clientWidth,offsetWidth的区别_html/css_WEB-ITnose
-
CSS3 实现特殊阴影 (学习笔记)_html/css_WEB-ITnose
-
CSS3学习笔记(3)-左右飞入的文字_html/css_WEB-ITnose
-
《HTML5与CSS3基础教程》学习笔记 --Three Day_html/css_WEB-ITnose
-
学习笔记:发现一个IE版本判断的好方法_html/css_WEB-ITnose