CSS3学习笔记(3)-左右飞入的文字_html/css_WEB-ITnose
前几天看到一个企业招聘的动画觉得很炫,里面有个企业介绍的文字是用飞入的效果做出来的,今天尝试了写了一下,感觉还不错~\(???)/~啦啦啦
下面来看我做的动态效果:
其实上面的效果很简单的,我的截图软件有问题,所以不是很清晰,但是大概的效果出现了~~~屏幕颜色从红变白是因为我把鼠标从页面上移到截图软件上关闭截图,不要被这个干扰~~~~
一、页面的主体布局
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>左右淡入的企业介绍</title> <link type="text/css" rel="stylesheet" href="css/animate.css" /> </head> <body> <div class="company"> <h2 id="上海世茂集团企业招聘">上海世茂集团企业招聘</h2> <h5 id="世茂集团-是以房地产开发为主的国际化企业集群-房地产界领袖企业之一">世茂集团,是以房地产开发为主的国际化企业集群,房地产界领袖企业之一。</h5> </div> </body></html>
上面就不用说了吧~~~~就四句话布局就完成了~~~我实在太懒了,一个多余的美观性布局我都不愿意写QAQ,最直接的代码是为了方便我以后复制。
二、CSS样式(主要是CSS3)
body{ overflow: hidden; /*此处需要设置溢出隐藏,否则文字起始位移超过页面大小就会在页面下方出现横的滚动条*/}.company{ width: 400px; margin: 0 auto; border: 1px #999999 solid;}/*定义一个名字为lefteaseinAnimate动画,实现从页面的左边淡入页面效果*/@keyframes lefteaseinAnimate{ 0%{ transform: translateX(-2000px); opacity: 0;} /*在0%时设置文字在想X轴-2000px位移处(左边),透明度为0,也就是看不见文字*/ 100%{ transform: translateX(0px); opacity: 1;} /*在100%时设置文字在想X轴0px位移处,也就是原始布局的位置,透明度为1,也就是文字可以看见了*/}@-webkit-keyframes lefteaseinAnimate{ 0%{ -webkit-transform: translateX(-2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;} }@-o-keyframes lefteaseinAnimate{ 0%{ -webkit-transform: translateX(-2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;} }@-ms-keyframes lefteaseinAnimate{ 0%{ -webkit-transform: translateX(-2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;} }@-moz-keyframes lefteaseinAnimate{ 0%{ -webkit-transform: translateX(-2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;} }.company_name{ animation: lefteaseinAnimate 1s ease 1; /*调用已定义好的动画lefteaseinAnimate,全程运行时间1S,进入的速度曲线为ease,只播放一次*/ -webkit-animation: lefteaseinAnimate 1s ease 1; -ms-animation: lefteaseinAnimate 1s ease 1; -o-animation: lefteaseinAnimate 1s ease 1; -moz-animation: lefteaseinAnimate 1s ease 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; }/*定义一个名字为righteaseinAnimate动画,实现从页面的右边淡入页面效果*/@keyframes righteaseinAnimate{ 0%{ transform: translateX(2000px); opacity: 0;} /*在0%时设置文字在想X轴2000px位移处(右边),透明度为0,也就是看不见文字*/ 100%{ transform: translateX(0px); opacity: 1;} /*在100%时设置文字在想X轴0px位移处,也就是原始布局的位置,透明度为1,也就是文字可以看见了*/}@-webkit-keyframes righteaseinAnimate{ 0%{ -webkit-transform: translateX(2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;}}@-o-keyframes righteaseinAnimate{ 0%{ -webkit-transform: translateX(2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;}}@-ms-keyframes righteaseinAnimate{ 0%{ -webkit-transform: translateX(2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;}}@-moz-keyframes righteaseinAnimate{ 0%{ -webkit-transform: translateX(2000px); opacity: 0;} 100%{ -webkit-transform: translateX(0px); opacity: 1;}}.company_introduce{ animation: righteaseinAnimate 1s ease 1; /*调用已定义好的动画righteaseinAnimate,全程运行时间1S,进入的速度曲线为ease,只播放一次*/ -webkit-animation: righteaseinAnimate 1s ease 1; -moz-animation: righteaseinAnimate 1s ease 1; -ms-animation: righteaseinAnimate 1s ease 1; -o-animation: righteaseinAnimate 1s ease 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; }
额,我觉得上面的很小儿科,注释我也写的很清楚,需要注意的是刚开始就要给body添加一个overflow: hidden; 设置溢出隐藏,否则文字起始位移超过页面大小就会在页面下方出现横的滚动条,这个也是我最后才发现的小问题,一句话就解决了~~~~~

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.
