CSS3学习笔记(1)-淡入的文字_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:35:55
原创
1285人浏览过

今天有空把前几天学的东西发一下,都是一些简单的东西,但是千里之行始于足下,我虽然走的慢,但是未停下前进的脚步~~~~~~~

下来看下我做的“淡入的文字”最终动态效果:

上面这个动画效果制作的过程是:

(1)先自定义一个透明度从0到1变化的动画,然后在animation中调用这个动画效果

立即学习前端免费学习笔记(深入)”;

(2)注意不同行文字出现的时间先后,这个通过animation中延时属性可以实现

(3)规定文字最终动态为动画的最终显示状态,否则文字显示完会自动消失,这个用animation-fill-mode可以实现

Get笔记
Get笔记

Get笔记,一款AI驱动的知识管理产品

Get笔记 125
查看详情 Get笔记

 

一、先来看看HTML中程序:

<!DOCTYPE html><html>    <head>        <meta charset="utf-8" />        <title>淡入的文字</title>        <link type="text/css" rel="stylesheet" href="css/animate.css" />    </head>    <body>        <div class="fade-in-words">            <div class="first-words">山一程,水一程,</div>            <div class="second-words">身向榆关那畔行,</div>            <div class="third-words">夜深千帐灯。</div>            <div class="four-words">风一更,雪一更,</div>            <div class="five-words">聒碎乡心梦不成,</div>            <div class="six-words">故园无此声。</div>        </div>    </body></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; }
登录后复制

上面的程序我在注释里面都写得很清楚,感兴趣的可以看我写的注释,我觉得比较简单,没有难度,但是需要注意浏览器前缀的添加,否则你懂得~~~~

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号