图片/图形

jQuery+css3炫酷3D互动图片画廊特效

阿里云

jQuery+css3炫酷3D互动图片画廊特效
这是一款效果非常炫酷的 jQuery 和 css3 3D 互动图片画廊特效插件。遗憾的是该特效只在 WEBKIT 内核的浏览器中可以看到效果。

HTML 代码

使用一个 gallery div 作为 wrapper。里面每个 div item 是一个用于 3D 倾斜和旋转的图片。

也想出现在这里?联系我们
创客主机
  1. <div class="gallery">
  2.   <div class="item">
  3.     <img align="left" src="img/c2NAjXD.jpg"/>
  4.   </div>
  5.   <div class="item">
  6.     <img align="left" src="img/FeCziip.png"/>
  7.   </div>
  8.   <div class="item">
  9.     <img align="left" src="img/OYlw7Pw.jpg?"/>
  10.   </div>
  11.   <div class="item">
  12.     <img align="left" src="img/MVammek.jpg?"/>
  13.   </div>
  14.   <div href="#" class="item">
  15.     <img align="left" src="img/gfp57KR.png"/>
  16.   </div>
  17.   <div class="item">
  18.     <img align="left" src="img/FeCziip.png"/>
  19.   </div>
  20. </div>

CSS 样式

3D 倾斜效果

  1. body {
  2.     margin: 0;
  3. }
  4.  
  5. .gallery {
  6.     margin: 0 auto;
  7.     width: 700px;
  8. }
  9. .gallery .item{
  10.     cursor: pointer;
  11.     position: relative;
  12.     display: block;
  13.     float: left;
  14.     z-index: 1;
  15. }
  16.  
  17. .gallery .item img {
  18.     -webkit-transition-property: all;
  19.     -webkit-transition-duration: 0.7s;
  20.     box-shadow:  -10px 10px 25px rgba(0,0,0,0.25);
  21.     max-width: 100%;
  22.     width: 190px;
  23.     height: 340px;
  24. }

首先,我们简单的将图片排成一排。注意,所有的图片都使用图像占位,如果你想使用自己的图片,那么建议图片的尺寸要一样大小。否则你可能需要其他一些 jQuery 插件来帮助你排列你的图片,如:Woomark 或 Masonry。

CSS 样式

  1. body {
  2.     background: url(img/LBONKMh.jpg) repeat fixed right bottom;
  3.     margin: 0;
  4. }
  5.  
  6. .gallery {
  7.     margin: 0 auto;
  8.     width: 700px;
  9. }
  10. .gallery .item{
  11.     cursor: pointer;
  12.     position: relative;
  13.     display: block;
  14.     float: left;
  15.     margin: 0 50px -175px;
  16.     z-index: 1;
  17.     transform-origin:20% 40%;
  18.     -webkit-transform: translate3d(0, -50px, 0) scaleY(0.57) rotate(-45deg);
  19.     -webkit-transition-property: all;
  20.     -webkit-transition-duration: 0.7s;
  21. }
  22.  
  23. .gallery .item img {
  24.     -webkit-transition-property: all;
  25.     -webkit-transition-duration: 0.7s;
  26.     box-shadow:  -10px 10px 25px rgba(0,0,0,0.25);
  27.     max-width: 100%;
  28.     width: 190px;
  29.     height: 340px;
  30. }

在这一步中将使用 CSS transform 来将图片进行 3d 倾斜。

CSS 样式

互动效果

  1. .gallery .item{
  2.     cursor: pointer;
  3.     position: relative;
  4.     display: block;
  5.     float: left;
  6.     margin: 0 50px -175px;
  7.     z-index: 1;
  8.     transform-origin:20% 40%;
  9.     -webkit-transform: translate3d(0, -50px, 0) scaleY(0.57) rotate(-45deg);
  10.     -webkit-transition-property: all;
  11.     -webkit-transition-duration: 0.7s;
  12. }
  13.  
  14. .gallery .item img {
  15.     -webkit-transition-property: all;
  16.     -webkit-transition-duration: 0.7s;
  17.     box-shadow:  -10px 10px 25px rgba(0,0,0,0.25);
  18.     max-width: 100%;
  19.     width: 190px;
  20.     height: 340px;
  21. }
  22.  
  23. .gallery .item:hover {
  24.     z-index: 2;
  25.     -webkit-transform: translate3d(0, -50px, 0) scaleY(0.57) rotate(-45deg) scale(1.2);
  26. }
  27.  
  28. .gallery .item.clicked{
  29.     z-index: 3;
  30.     -webkit-transform:none;
  31. }

JAVASCRIPT

  1. $(document).ready(function() {
  2.     $(".item").click(function (e) {
  3.       e.stopPropagation();
  4.       $(".item").removeClass("clicked");
  5.       $(this).toggleClass("clicked");
  6.       $("body").addClass("showing-item");
  7.     });
  8.     $('html').click(function() {
  9.        $(".item").removeClass("clicked");
  10.        $("body").removeClass("showing-item");
  11.     });
  12. });

确保在上面代码之前引入 jQuery 文件。这一步将制作出鼠标滑过图片和点击图片是的效果。

HTML 结构

添加图片提示效果

  1. <div class="gallery">
  2.   <div class="item">
  3.     <img align="left" src="img/c2NAjXD.jpg"/>
  4.     <span class="caption">
  5.       <h1>
  6.         htmleaf.com
  7.       </h1>
  8.       <p>
  9.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  10.       </p>
  11.     </span>
  12.   </div>
  13.   <div class="item">
  14.     <img align="left" src="img/FeCziip.png"/>
  15.     <span class="caption">
  16.       <h1>
  17.         htmleaf.com
  18.       </h1>
  19.       <p>
  20.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  21.       </p>
  22.     </span>
  23.   </div>
  24.   <div class="item">
  25.     <img align="left" src="img/OYlw7Pw.jpg?1"/>
  26.     <span class="caption">
  27.       <h1>
  28.         htmleaf.com
  29.       </h1>
  30.       <p>
  31.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  32.       </p>
  33.     </span>
  34.   </div>
  35.   <div class="item">
  36.     <img align="left" src="img/MVammek.jpg?1"/>
  37.     <span class="caption">
  38.       <h1>
  39.         htmleaf.com
  40.       </h1>
  41.       <p>
  42.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  43.       </p>
  44.     </span>
  45.   </div>
  46.   <div href="#" class="item">
  47.     <img align="left" src="img/gfp57KR.png"/>
  48.     <span class="caption">
  49.       <h1>
  50.         htmleaf.com
  51.       </h1>
  52.       <p>
  53.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  54.       </p>
  55.     </span>
  56.   </div>
  57.   <div class="item">
  58.     <img align="left" src="img/FeCziip.png"/>
  59.     <div class="caption">
  60.       <h1>
  61.         htmleaf.com
  62.       </h1>
  63.       <p>
  64.         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  65.       </p>
  66.     </div>
  67.   </div>
  68. </div>

CSS 样式

  1. body {
  2.     background: url(img/LBONKMh.jpg) repeat fixed right bottom;
  3.     margin: 0;
  4. }
  5. body.showing-item .item:not(.clicked){
  6.      -webkit-filter: blur(2px) grayscale(0.5) opacity(0.8);
  7. }
  8. .gallery {
  9.     margin: 0 auto;
  10.     width: 700px;
  11. }
  12. .gallery .item{
  13.     cursor: pointer;
  14.     position: relative;
  15.     display: block;
  16.     float: left;
  17.     margin: 0 50px -175px;
  18.     z-index: 1;
  19.     transform-origin:20% 40%;
  20.     -webkit-transform: translate3d(0, -50px, 0) scaleY(0.57) rotate(-45deg);
  21.     -webkit-transition-property: all;
  22.     -webkit-transition-duration: 0.7s;
  23. }
  24. .gallery .item:hover {
  25.     z-index: 2;
  26.     -webkit-transform: translate3d(0, -50px, 0) scaleY(0.57) rotate(-45deg) scale(1.2);
  27. }
  28. .gallery .item.clicked{
  29.     z-index: 3;
  30.     -webkit-transform:none;
  31. }
  32. .gallery .item .caption{
  33.     display: none;
  34.     border-radius: 3px 3px;
  35.     font-family: helvetica, arial;
  36.     background: white;
  37.     padding: 10px;
  38.     box-shadow: 0 1px 2px rgba(0,0,0,0.45);
  39.     width: 300px;
  40. }
  41. .gallery .item .caption:after{
  42. background-color: #fff;
  43.     box-shadow: -2px 2px 2px 0 rgba( 178, 178, 178, .4 );
  44.     content: "\00a0";
  45.     display: block;
  46.     height: 15px;
  47.     left: -5px;
  48.     position: absolute;
  49.     top: 50%;
  50.     margin-top: -7px;
  51.     -webkit-transform: rotate( 45deg );
  52.     width:  15px;
  53. }
  54. .gallery .item.left .caption:after{
  55.     right: -8px;
  56.     left: auto;
  57.     box-shadow: 2px -1px 2px 0 rgba( 178, 178, 178, .4 );
  58. }
  59. .gallery .item .caption h1{
  60.     color: black;
  61.     font-weight: 100;
  62.     text-align: center;
  63.     letter-spacing: -1px;
  64.     margin: 0 0 5px;
  65.     margin-bottom: 10px;
  66. border-bottom: 1px solid #EFEFEF;
  67. padding-bottom: 10px;
  68. }
  69. .gallery .item .caption p{
  70.      color: #444;  
  71.     font-weight: 100;}
  72. .gallery .item.clicked .caption{
  73.     position: absolute;
  74.     top: 25px;
  75.     display: inline; 
  76.     -webkit-transition-property: display;
  77.     -webkit-transition-duration: 0.7s;
  78. }
  79. .gallery .item.clicked.right .caption {
  80.     left: 115%;
  81.     margin-left: 15px;
  82.  
  83. }
  84. .gallery .item.clicked.left .caption {
  85.     right: 115%;
  86.      margin-right: 15px;
  87. }
  88. .gallery .item.clicked img {
  89.     box-shadow:  0 0 25px rgba(0,0,0,0.25);
  90.     -webkit-transform: scale(1.25);
  91. }
  92. .gallery .item img {
  93.     -webkit-transition-property: all;
  94.     -webkit-transition-duration: 0.7s;
  95.     box-shadow:  -10px 10px 25px rgba(0,0,0,0.25);
  96.     max-width: 100%;
  97.     width: 190px;
  98.     height: 340px;
  99. }

JAVASCRIPT

  1. $(document).ready(function () {
  2.     $(".item").click(function (e) {
  3.         e.stopPropagation();
  4.         $(".item").removeClass("clicked");
  5.         $(this).toggleClass("clicked");
  6.         $("body").addClass("showing-item");
  7.  
  8.         var offset = $(this).offset();
  9.         var pos = offset.left + $(this).width()
  10.         var center = $(".gallery").width() / 2;
  11.         if (pos > center) {
  12.             var align = "left";
  13.         } else {
  14.             var align = "right";
  15.         }
  16.         $(this).removeClass(".left, .right").addClass(align);
  17.  
  18.         return false;
  19.     });
  20.  
  21.     $('html').click(function () {
  22.         $(".item").removeClass("clicked");
  23.         $("body").removeClass("showing-item");
  24.     });
  25. });

jQuery+css3 炫酷 3D 互动图片画廊特效

已有 450 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!