css 3D翻转图片动画
本例用了2个js
jquery.easing.1.3.js和modernizr.2.5.3.min.js
演示页面可以查看
CSS Code
- <style type="text/css">
- #note {
- font-size:11px;
- color:#333;
- padding:10px;
- border:1px solid #b99f35;
- background:#f4eccb;
- border-radius: 3px;
- }
- .thumb {
- display:block;
- width:200px;
- height:140px;
- position:relative;
- margin-bottom:20px;
- margin-right:20px;
- float:left;
- }
- .thumb-wrapper {
- display:block;
- width:100%;
- height:100%;
- }
- .thumb img {
- width:100%;
- height:100%;
- position:absolute;
- display:block;
- }
- .thumb .thumb-detail {
- display:block;
- width:100%;
- height:100%;
- position:absolute;
- background:#eee;
- font-family:arial;
- font-weight:bold;
- font-size:16px;
- }
- .thumb .thumb-detail a {
- display:block;
- width:100%;
- height:100%;
- text-transform:uppercase;
- font-weight:bold;
- color:#333;
- text-decoration:none;
- font-family: 'Open Sans', sans-serif;
- letter-spacing:-1px;
- padding:10px;
- font-size:18px;
- }
- /*
- * Without CSS3
- */
- .thumb.scroll {
- overflow: hidden;
- }
- .thumb.scroll .thumb-detail {
- bottombottom:-280px;
- }
- /*
- * CSS3 Flip
- */
- .thumb.flip {
- -webkit-perspective:800px;
- -moz-perspective:800px;
- -ms-perspective:800px;
- -o-perspective:800px;
- perspective:800px;
- }
- .thumb.flip .thumb-wrapper {
- -webkit-transition: -webkit-transform 1s;
- -moz-transition: -moz-transform 1s;
- -ms-transition: -moz-transform 1s;
- -o-transition: -moz-transform 1s;
- transition: -moz-transform 1s;
- -webkit-transform-style: preserve-3d;
- -moz-transform-style: preserve-3d;
- -ms-transform-style: preserve-3d;
- -o-transform-style: preserve-3d;
- transform-style: preserve-3d;
- }
- .thumb.flip .thumb-detail {
- -webkit-transform: rotateY(-180deg);
- -moz-transform: rotateY(-180deg);
- -ms-transform: rotateY(-180deg);
- -o-transform: rotateY(-180deg);
- transform: rotateY(-180deg);
- }
- .thumb.flip img,
- .thumb.flip .thumb-detail {
- -webkit-backface-visibility: hidden;
- -moz-backface-visibility: hidden;
- -ms-backface-visibility: hidden;
- -o-backface-visibility: hidden;
- backface-visibility: hidden;
- }
- .thumb.flip .flipIt {
- -webkit-transform: rotateY(-180deg);
- -moz-transform: rotateY(-180deg);
- -ms-transform: rotateY(-180deg);
- -o-transform: rotateY(-180deg);
- transform: rotateY(-180deg);
- }
- </style>
JavaScript Code
- <script type="text/javascript">
- $(function () {
- if ($('html').hasClass('csstransforms3d')) {
- $('.thumb').removeClass('scroll').addClass('flip');
- $('.thumb.flip').hover(
- function () {
- $(this).find('.thumb-wrapper').addClass('flipIt');
- },
- function () {
- $(this).find('.thumb-wrapper').removeClass('flipIt');
- }
- );
- } else {
- $('.thumb').hover(
- function () {
- $(this).find('.thumb-detail').stop().animate({bottom:0}, 500, 'easeOutCubic');
- },
- function () {
- $(this).find('.thumb-detail').stop().animate({bottom: ($(this).height() * -1) }, 500, 'easeOutCubic');
- }
- );
- }
- });
- </script>
XML/HTML Code
- <div id="container">
- <div class="thumb scroll">
- <div class="thumb-wrapper">
- <img src="images/1.jpeg" alt="" />
- <div class="thumb-detail">
- <a href="">
- 文字1
- </a>
- </div>
- </div>
- </div>
- <div class="thumb scroll">
- <div class="thumb-wrapper">
- <img src="images/2.jpeg" alt="" />
- <div class="thumb-detail">
- <a href="">
- 文字2
- </a>
- </div>
- </div>
- </div>
- <div class="thumb scroll">
- <div class="thumb-wrapper">
- <img src="images/3.jpeg" alt="" />
- <div class="thumb-detail">
- <a href="">
- 文字3
- </a>
- </div>
- </div>
- </div>
- </div>
原文地址:http://www.freejs.net/article_jquerytupiantexiao_93.html