CSS3文字旋转替换效果

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 CSS3文字旋转替换效果 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

CSS3文字旋转替换效果

HTML代码(index.html):

<!DOCTYPE html>
<html lang="en">
    <head>
		<meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
        <title>Rotating Words with CSS Animations</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <meta name="description" content="Rotating Words with CSS Animations" />
        <meta name="keywords" content="css3, animations, rotating words, sentence, typography" />
        <meta name="author" content="Codrops" />
        <link rel="shortcut icon" href="../favicon.ico"> 
		<link rel="stylesheet" type="text/css" href="css/demo.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
		<script src="js/modernizr.custom.72111.js"></script>
		<style>
			.no-cssanimations .rw-wrapper .rw-sentence span:first-child{
				opacity: 1;
			}
		</style>
		<!--[if lt IE 9]> 
			<style>
				.rw-wrapper{ display: none; } 
				.rw-sentence-IE{ display: block;  }
			</style>
		<![endif]-->
    </head>
    <body>
        <div class="container">
			<!-- Codrops top bar -->
            <div class="codrops-top">
                <a href="http://tympanus.net/Tutorials/CSS3ContentTabs/">
                    <strong>&laquo; Previous Demo: </strong>Animated Content Tabs with CSS3
                </a>
                <span class="right">
                    <a href="http://tympanus.net/codrops/2012/04/17/rotating-words-with-css-animations">
                        <strong>Back to the Codrops Article</strong>
                    </a>
                </span>
                <div class="clr"></div>
            </div><!--/ Codrops top bar -->
			<header>
				<h1>Rotating Words <span>with CSS Animations</span></h1>
				<nav class="codrops-demos">
					<a class="current-demo" href="index.html">Demo 1</a>
					<a href="index2.html">Demo 2</a>
					<a href="index3.html">Demo 3</a>
					<a href="index4.html">Demo 4</a>
					<a href="index5.html">Demo 5</a>
				</nav>
			</header>
			<section class="rw-wrapper">
				<h2 class="rw-sentence">
					<span>Real poetry is like</span>
					<br />
					<span>creating beautiful butterflies</span>
					<br />
					<span>with a silent touch of</span>
					<div class="rw-words rw-words-1">
						<span>spice</span>
						<span>colors</span>
						<span>happiness</span>
						<span>wonder</span>
						<span>sugar</span>
						<span>happiness</span>
					</div>
				</h2>
			</section>
			<h2 class="rw-sentence-IE">Real poetry is like creating beautiful butterflies with a silent touch of spice</h2>
        </div>
    </body>
</html>









JS代码(modernizr.custom.72111.js):

/* Modernizr 2.5.3 (Custom Build) | MIT & BSD * Build:http://www.modernizr.com/download/#-cssanimations-shiv-cssclasses-testprop-testallprops-domprefixes-load */
;
	window.Modernizr=function(a,b,c){
	function x(a){
	j.cssText=a}
function y(a,b){
	return x(prefixes.join(a+";
	")+(b||""))}
function z(a,b){
	return typeof a===b}
function A(a,b){
	return!!~(""+a).indexOf(b)}
function B(a,b){
	for(var d in a)if(j[a[d]]!==c)return b=="pfx"?a[d]:!0;
	return!1}
function C(a,b,d){
	for(var e in a){
	var f=b[a[e]];
	if(f!==c)return d===!1?a[e]:z(f,"function")?f.bind(d||b):f}
return!1}
function D(a,b,c){
	var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+n.join(d+" ")+d).split(" ");
	return z(b,"string")||z(b,"undefined")?B(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),C(e,b,c))}
var d="2.5.3",e={
}
,f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={
}
.toString,m="Webkit Moz O ms",n=m.split(" "),o=m.toLowerCase().split(" "),p={
}
,q={
}
,r={
}
,s=[],t=s.slice,u,v={
}
.hasOwnProperty,w;
	!z(v,"undefined")&&!z(v.call,"undefined")?w=function(a,b){
	return v.call(a,b)}
:w=function(a,b){
	return b in a&&z(a.constructor.prototype[b],"undefined")}
,Function.prototype.bind||(Function.prototype.bind=function(b){
	var c=this;
	if(typeof c!="function")throw new TypeError;
	var d=t.call(arguments,1),e=function(){
	if(this instanceof e){
	var a=function(){
}
;
	a.prototype=c.prototype;
	var f=new a,g=c.apply(f,d.concat(t.call(arguments)));
	return Object(g)===g?g:f}
return c.apply(b,d.concat(t.call(arguments)))}
;
	return e}
),p.cssanimations=function(){
	return D("animationName")}
;
	for(var E in p)w(p,E)&&(u=E.toLowerCase(),e[u]=p[E](),s.push((e[u]?"":"no-")+u));
	return x(""),i=k=null,function(a,b){
	function g(a,b){
	var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;
	return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}
function h(){
	var a=k.elements;
	return typeof a=="string"?a.split(" "):a}
function i(a){
	var b={
}
,c=a.createElement,e=a.createDocumentFragment,f=e();
	a.createElement=function(a){
	var e=(b[a]||(b[a]=c(a))).cloneNode();
	return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e}
,a.createDocumentFragment=Function("h,f","return function(){
	var n=f.cloneNode(),c=n.createElement;
	h.shivMethods&&("+h().join().replace(/\w+/g,function(a){
	return b[a]=c(a),f.createElement(a),'c("'+a+'")'}
)+");
	return n}
")(k,f)}
function j(a){
	var b;
	return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{
	display:block}
audio{
	display:none}
canvas,video{
	display:inline-block;
	*display:inline;
	*zoom:1}
[hidden]{
	display:none}
audio[controls]{
	display:inline-block;
	*display:inline;
	*zoom:1}
mark{
	background:#FF0;
	color:#000}
")),f||(b=!i(a)),b&&(a.documentShived=b),a)}
var c=a.html5||{
}
,d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;
	(function(){
	var a=b.createElement("a");
	a.innerHTML="<xyz></xyz>",e="hidden"in a,f=a.childNodes.length==1||function(){
	try{
	b.createElement("a")}
catch(a){
	return!0}
var c=b.createDocumentFragment();
	return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}
()}
)();
	var k={
	elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j}
;
	a.html5=k,j(b)}
(this,b),e._version=d,e._domPrefixes=o,e._cssomPrefixes=n,e.testProp=function(a){
	return B([a])}
,e.testAllProps=D,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+s.join(" "):""),e}
(this,this.document),function(a,b,c){
	function d(a){
	return o.call(a)=="[object Function]"}
function e(a){
	return typeof a=="string"}
function f(){
}
function g(a){
	return!a||a=="loaded"||a=="complete"||a=="uninitialized"}
function h(){
	var a=p.shift();
	q=1,a?a.t?m(function(){
	(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)}
,0):(a(),h()):q=0}
function i(a,c,d,e,f,i,j){
	function k(b){
	if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){
	a!="img"&&m(function(){
	t.removeChild(l)}
,50);
	for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}
}
var j=j||B.errorTimeout,l={
}
,o=0,r=0,u={
	t:d,s:c,e:f,a:i,x:j}
;
	y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){
	k.call(this,r)}
,p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}
function j(a,b,c,d,f){
	return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}
function k(){
	var a=B;
	return a.loader={
	load:j,i:0}
,a}
var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={
}
.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){
	return o.call(a)=="[object Array]"}
,x=[],y={
}
,z={
	timeout:function(a,b){
	return b.length&&(a.timeout=b[0]),a}
}
,A,B;
	B=function(a){
	function b(a){
	var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={
	url:c,origUrl:c,prefixes:a}
,e,f,g;
	for(f=0;
	f<d;
	f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));
	for(f=0;
	f<b;
	f++)c=x[f](c);
	return c}
function g(a,e,f,g,i){
	var j=b(a),l=j.autoCallback;
	j.url.split(".").pop().split("?").shift(),j.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]||h),j.instead?j.instead(a,e,f,g,i):(y[j.url]?j.noexec=!0:y[j.url]=1,f.load(j.url,j.forceCSS||!j.forceJS&&"css"==j.url.split(".").pop().split("?").shift()?"c":c,j.noexec,j.attrs,j.timeout),(d(e)||d(l))&&f.load(function(){
	k(),e&&e(j.origUrl,i,g),l&&l(j.origUrl,i,g),y[j.url]=2}
)))}
function i(a,b){
	function c(a,c){
	if(a){
	if(e(a))c||(j=function(){
	var a=[].slice.call(arguments);
	k.apply(this,a),l()}
),g(a,j,b,0,h);
	else if(Object(a)===a)for(n in m=function(){
	var b=0,c;
	for(c in a)a.hasOwnProperty(c)&&b++;
	return b}
(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){
	var a=[].slice.call(arguments);
	k.apply(this,a),l()}
:j[n]=function(a){
	return function(){
	var b=[].slice.call(arguments);
	a&&a.apply(this,b),l()}
}
(k[n])),g(a[n],j,b,n,h))}
else!c&&l()}
var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;
	c(h?a.yep:a.nope,!!i),i&&c(i)}
var j,l,m=this.yepnope.loader;
	if(e(a))g(a,0,m,0);
	else if(w(a))for(j=0;
	j<a.length;
	j++)l=a[j],e(l)?g(l,0,m,0):w(l)?B(l):Object(l)===l&&i(l,m);
	else Object(a)===a&&i(a,m)}
,B.addPrefix=function(a,b){
	z[a]=b}
,B.addFilter=function(a){
	x.push(a)}
,B.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){
	b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"}
,0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){
	var k=b.createElement("script"),l,o,e=e||B.errorTimeout;
	k.src=a;
	for(o in d)k.setAttribute(o,d[o]);
	c=j?h:c||f,k.onreadystatechange=k.onload=function(){
	!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)}
,m(function(){
	l||(l=1,c(1))}
,e),i?k.onload():n.parentNode.insertBefore(k,n)}
,a.yepnope.injectCss=function(a,c,d,e,g,i){
	var e=b.createElement("link"),j,c=i?h:c||f;
	e.href=a,e.rel="stylesheet",e.type="text/css";
	for(j in d)e.setAttribute(j,d[j]);
	g||(n.parentNode.insertBefore(e,n),m(c,0))}
}
(this,document),Modernizr.load=function(){
	yepnope.apply(window,[].slice.call(arguments,0))}
;
	

CSS代码(demo.css):

@import url('normalize.css');/* General Demo Style */
html{height:100%;}
body{font-family:'Open Sans Condensed','Arial Narrow',serif;font-weight:400;font-size:15px;color:#333;-webkit-font-smoothing:antialiased;-moz-font-smoothing:antialiased;font-smoothing:antialiased;overflow-x:hidden;}
a{color:#555;text-decoration:none;}
.container{width:100%;min-width:320px;position:relative;}
.clr{clear:both;padding:0;height:0;margin:0;}
.container > header{margin:10px;padding:10px;position:relative;display:block;text-align:left;}
.container > header h1{font-size:36px;line-height:40px;margin:0;padding:0;position:relative;font-weight:300;color:#333;text-shadow:1px 1px 1px rgba(0,0,0,0.1);}
.container > header h1 span{font-weight:700;}
.container > header h2{font-size:14px;font-weight:300;letter-spacing:2px;text-transform:uppercase;margin:0;padding:15px 0 5px 0;color:#6190ca;text-shadow:1px 1px 1px rgba(255,255,255,0.7);}
/* Header Style */
.codrops-top{line-height:24px;font-size:11px;background:#fff;background:rgba(255,255,255,0.6);text-transform:uppercase;z-index:9999;position:relative;font-family:Cambria,Georgia,serif;box-shadow:1px 0px 2px rgba(0,0,0,0.2);}
.codrops-top a{padding:0px 10px;letter-spacing:1px;color:#333;display:inline-block;}
.codrops-top a:hover{background:rgba(255,255,255,0.3);}
.codrops-top span.right{float:right;}
.codrops-top span.right a{float:left;display:block;}
/* Demo Buttons Style */
.codrops-demos{text-align:left;display:block;line-height:30px;padding:5px 0px;}
.codrops-demos a{display:inline-block;margin:0px 4px;padding:0px 6px;color:#aaa;line-height:20px;font-size:13px;text-shadow:1px 1px 1px #fff;border:1px solid #fff;background:#ffffff;/* Old browsers */
background:-moz-linear-gradient(top,#ffffff 0%,#f6f6f6 47%,#ededed 100%);/* FF3.6+ */
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#ffffff),color-stop(47%,#f6f6f6),color-stop(100%,#ededed));/* Chrome,Safari4+ */
background:-webkit-linear-gradient(top,#ffffff 0%,#f6f6f6 47%,#ededed 100%);/* Chrome10+,Safari5.1+ */
background:-o-linear-gradient(top,#ffffff 0%,#f6f6f6 47%,#ededed 100%);/* Opera 11.10+ */
background:-ms-linear-gradient(top,#ffffff 0%,#f6f6f6 47%,#ededed 100%);/* IE10+ */
background:linear-gradient(top,#ffffff 0%,#f6f6f6 47%,#ededed 100%);/* W3C */
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff',endColorstr='#ededed',GradientType=0 );/* IE6-9 */
box-shadow:0px 1px 1px rgba(0,0,0,0.3);}
.codrops-demos a:hover{color:#333;}
.codrops-demos a:active{background:#fff;}
.codrops-demos a.current-demo,.codrops-demos a.current-demo:hover{background:#fff;color:#aaa;filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff',endColorstr='#ffffff',GradientType=0 );/* IE6-9 */
}
.rw-sentence-IE{display:none;padding:30px;}

CSS代码(style.css):

body{background:#fff url(../images/lghtmesh.png) repeat center center;}
.rw-wrapper{width:80%;position:relative;margin:110px auto 0 auto;font-family:'Bree Serif';padding:10px;}
.rw-sentence{margin:0;text-align:left;text-shadow:1px 1px 1px rgba(255,255,255,0.8);}
.rw-sentence span{color:#444;font-size:200%;font-weight:normal;}
.rw-words{display:inline;text-indent:10px;}
.rw-words-1 span{position:absolute;opacity:0;overflow:hidden;color:#6b969d;-webkit-animation:rotateWord 18s linear infinite 0s;-moz-animation:rotateWord 18s linear infinite 0s;-o-animation:rotateWord 18s linear infinite 0s;-ms-animation:rotateWord 18s linear infinite 0s;animation:rotateWord 18s linear infinite 0s;}
.rw-words-1 span:nth-child(2){-webkit-animation-delay:3s;-moz-animation-delay:3s;-o-animation-delay:3s;-ms-animation-delay:3s;animation-delay:3s;color:#6b889d;}
.rw-words-1 span:nth-child(3){-webkit-animation-delay:6s;-moz-animation-delay:6s;-o-animation-delay:6s;-ms-animation-delay:6s;animation-delay:6s;color:#6b739d;}
.rw-words-1 span:nth-child(4){-webkit-animation-delay:9s;-moz-animation-delay:9s;-o-animation-delay:9s;-ms-animation-delay:9s;animation-delay:9s;color:#7a6b9d;}
.rw-words-1 span:nth-child(5){-webkit-animation-delay:12s;-moz-animation-delay:12s;-o-animation-delay:12s;-ms-animation-delay:12s;animation-delay:12s;color:#8d6b9d;}
.rw-words-1 span:nth-child(6){-webkit-animation-delay:15s;-moz-animation-delay:15s;-o-animation-delay:15s;-ms-animation-delay:15s;animation-delay:15s;color:#9b6b9d;}
@-webkit-keyframes rotateWord{0%{opacity:0;}
2%{opacity:0;-webkit-transform:translateY(-30px);}
5%{opacity:1;-webkit-transform:translateY(0px);}
17%{opacity:1;-webkit-transform:translateY(0px);}
20%{opacity:0;-webkit-transform:translateY(30px);}
80%{opacity:0;}
100%{opacity:0;}
}
@-moz-keyframes rotateWord{0%{opacity:0;}
2%{opacity:0;-moz-transform:translateY(-30px);}
5%{opacity:1;-moz-transform:translateY(0px);}
17%{opacity:1;-moz-transform:translateY(0px);}
20%{opacity:0;-moz-transform:translateY(30px);}
80%{opacity:0;}
100%{opacity:0;}
}
@-o-keyframes rotateWord{0%{opacity:0;}
2%{opacity:0;-o-transform:translateY(-30px);}
5%{opacity:1;-o-transform:translateY(0px);}
17%{opacity:1;-o-transform:translateY(0px);}
20%{opacity:0;-o-transform:translateY(30px);}
80%{opacity:0;}
100%{opacity:0;}
}
@-ms-keyframes rotateWord{0%{opacity:0;}
2%{opacity:0;-ms-transform:translateY(-30px);}
5%{opacity:1;-ms-transform:translateY(0px);}
17%{opacity:1;-ms-transform:translateY(0px);}
20%{opacity:0;-ms-transform:translateY(30px);}
80%{opacity:0;}
100%{opacity:0;}
}
@keyframes rotateWord{0%{opacity:0;}
2%{opacity:0;transform:translateY(-30px);}
5%{opacity:1;transform:translateY(0px);}
17%{opacity:1;transform:translateY(0px);}
20%{opacity:0;transform:translateY(30px);}
80%{opacity:0;}
100%{opacity:0;}
}
@media screen and (max-width:768px){.rw-sentence{font-size:18px;}
}
@media screen and (max-width:320px){.rw-sentence{font-size:9px;}
}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
184.06 KB
Html CSS3特效
最新结算
股权转让协议意向书模板
类型: .docx 金额: CNY 2.23¥ 状态: 待结算 详细>
股权转让协议意向书模板
类型: .docx 金额: CNY 0.28¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 2.39¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 0.3¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章