你的位置:首页 > 网页设计

[网页设计]使用transform和transition制作CSS3动画


<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>使用transform和transition制作CSS3动画</title>
<style>
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input{margin:0; padding:0;}
/* HTML ELEMENTS */
body { background-color:#deddcd; font:14px/21px Arial,Helvetica,sans-serif; }
h1 { font: bold 65px/60px Helvetica, Arial, Sans-serif; text-align: center; color: #eee; text-shadow: 0px 2px 6px #333; }
h1 small{ font-size: 20px; text-transform:uppercase; letter-spacing: 14px; display: block; color: #000; }
h2 a { display: block; text-decoration: none; margin: 0 0 30px 0; font: italic 45px Georgia, Times, Serif; text-align: center; color: #bfe1f1; text-shadow: 0px 2px 6px #333; }
h2 a:hover { color: #90bcd0; }
/* COMMON CLASSES */
.break { clear:both; }
/* WRAPPER */
#wrapper { width:960px; margin:40px auto; }
/* CONTENT */
#content { }
#content .info { padding:10px; }
/* MOVIE POSTERS */
#movieposters { list-style:none; margin:100px 0; height:550px; }
#movieposters li { display:inline; float:left;
-webkit-perspective: 500; -webkit-transform-style: preserve-3d;
-webkit-transition-property: perspective; -webkit-transition-duration: 0.5s; }
#movieposters li:hover { -webkit-perspective: 5000; }
#movieposters li img { border:10px solid #fcfafa; -webkit-transform: rotateY(30deg);
-moz-box-shadow:0 3px 10px #888; -webkit-box-shadow:0 3px 10px #888;
-webkit-transition-property: transform; -webkit-transition-duration: 0.5s; }
#movieposters li:hover img { -webkit-transform: rotateY(0deg); }
.movieinfo { border:10px solid #fcfafa; padding:20px; width:200px; height:180px; background-color:#deddcd; margin:-195px 0 0 55px; position:absolute;
-moz-box-shadow:0 20px 40px #888; -webkit-box-shadow:0 20px 40px #888;
-webkit-transform: translateZ(30px) rotateY(30deg);
-webkit-transition-property: transform, box-shadow, margin; -webkit-transition-duration: 0.5s; }
#movieposters li:hover .movieinfo { -webkit-transform: rotateY(0deg); -webkit-box-shadow:0 5px 10px #888; margin:-175px 0 0 30px; }
.movieinfo h3 { color:#7a3f3a; font-variant: small-caps; font-family:Georgia,serif,Times; text-align:center; padding-bottom:15px; }
.movieinfo p { padding-bottom:15px; }
.movieinfo a { background-color:#7a3f3a; padding:5px 10px; color:#eee; text-decoration:none; display:block; width:80px; text-align:center; margin:0 auto;
-moz-border-radius:5px; -webkit-border-radius:5px; }
.movieinfo a:hover, .movieinfo a:focus { background-color:#6a191f; color:#fff; }
</style>

</head>
<body>
<div>http://www.999jiujiu.com/</div>
<div id="wrapper">
<ul id="movieposters">
<li>
<img src="http://p8.qhimg.com/t01f085962622ed5302.jpg" alt="Iron Man 2" />
<div >
<h3>Iron Man 2</h3>
<p>With the world now aware of his dual life as the armored superhero Iron Man, billionaire inventor Tony...</p>
<a href="#" title="Iron Man 2">More info</a>
</div>
</li>
<li>
<img src="http://p8.qhimg.com/t01f085962622ed5302.jpg" alt="The Last Airbender" />
<div >
<h3>The Last Airbender</h3>
<p>The story follows the adventures of Aang, a young successor to a long line of Avatars, who must put his...</p>
<a href="#" title="Iron Man 2">More info</a>
</div>
</li>
<li>
<img src="http://p8.qhimg.com/t01f085962622ed5302.jpg" alt="Tron Legacy" />
<div >
<h3>Tron Legacy</h3>
<p>Sam Flynn, the tech-savvy 27-year-old son of Kevin Flynn, looks into his father's disappearance and finds...</p>
<a href="#" title="Tron Legacy">More info</a>
</div>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F7b1b0a3f92f550c351b60c95bab723a4' type='text/javascript'%3E%3C/script%3E"));
</script>
</body>
</html>