鼠标悬停动态倾斜多重效果展示代码

  • 698
  • 0
  • 0
html5鼠标悬停图片文字3D视差动画特效
元素的HTML结构
  1. <a href="#" class="tilter tilter--2">
  2.         <figure class="tilter__figure">
  3.                 <img class="tilter__image" src="img/3.jpg" alt="img03" />
  4.                 <div class="tilter__deco tilter__deco--shine"><div></div></div>
  5.                 <div class="tilter__deco tilter__deco--overlay"></div>
  6.                 <figcaption class="tilter__caption">
  7.                         <h3 class="tilter__title">Helen Portland</h3>
  8.                         <p class="tilter__description">Seattle</p>
  9.                 </figcaption>
  10.                 <svg class="tilter__deco tilter__deco--lines" viewBox="0 0 300 415">
  11.                         <path d="M20.5,20.5h260v375h-260V20.5z" />
  12.                 </svg>
  13.         </figure>
  14. </a>
复制代码
元素的样式
  1. .tilter {
  2.         position: relative;
  3.         display: block;
  4.         flex: none;
  5.         width: 300px;
  6.         height: 415px;
  7.         margin: 1.5em 2.5em;
  8.         color: #fff;
  9.         perspective: 1000px;
  10. }

  11. .tilter * {
  12.         pointer-events: none;
  13. }

  14. .tilter:hover,
  15. .tilter:focus {
  16.         color: #fff;
  17.         outline: none;
  18. }

  19. .tilter__figure,
  20. .tilter__image {
  21.         display: block;
  22.         width: 100%;
  23.         height: 100%;
  24.         margin: 0;
  25. }

  26. .tilter__figure > * {
  27.         transform: translateZ(0px); /* Force correct stacking order */
  28. }

  29. .tilter__figure {
  30.         position: relative;
  31. }

  32. .tilter__figure::before {
  33.         content: '';
  34.         position: absolute;
  35.         top: 5%;
  36.         left: 5%;
  37.         width: 90%;
  38.         height: 90%;
  39.         box-shadow: 0 30px 20px rgba(35,32,39,0.5);
  40. }

  41. .tilter__deco {
  42.         position: absolute;
  43.         top: 0;
  44.         left: 0;
  45.         overflow: hidden;
  46.         width: 100%;
  47.         height: 100%;
  48. }

  49. .tilter__deco--overlay {
  50.         background-image: linear-gradient(45deg, rgba(226, 60, 99, 0.4), rgba(145, 58, 252, 0.4), rgba(16, 11, 192, 0.4));
  51. }

  52. .tilter__deco--shine div {
  53.         position: absolute;
  54.         top: -50%;
  55.         left: -50%;
  56.         width: 200%;
  57.         height: 200%;
  58.         background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%);
  59. }

  60. .tilter__deco--lines {
  61.         fill: none;
  62.         stroke: #fff;
  63.         stroke-width: 1.5px;
  64. }

  65. .tilter__caption {
  66.         position: absolute;
  67.         bottom: 0;
  68.         width: 100%;
  69.         padding: 4em;
  70. }

  71. .tilter__title {
  72.         font-family: 'Abril Fatface', serif;
  73.         font-size: 2.5em;
  74.         font-weight: normal;
  75.         line-height: 1;
  76.         margin: 0;
  77. }

  78. .tilter__description {
  79.         font-size: 0.85em;
  80.         margin: 1em 0 0 0;
  81.         letter-spacing: 0.15em;
  82. }
复制代码
JavaScript
在选项中,我们可以定义每个动画元素将具有的动作:
我们可以传递以下内容:所有轴和动画的平移和旋转(持续时间,缓动和弹性 - 与anime.js选项相同的方式)以恢复为默认样式。
对于平移和旋转,我们可以通过以下方式定义每个轴的值:
number :例如翻译:{X:10,Y:-10}意味着该元件将沿x轴从-10px从10px的移动为10px(我们着手从左至右的小鼠)和在y轴到-10px(当我们将鼠标从上到下移动时)。
array :如翻译:{Z:[10,100]}这意味着该元件将沿z轴从10px的移动到100像素(如我们从顶端移动鼠标到下)

  1. Initialize:

  2. new TiltFx(el, [options]);

  3. The options:

  4. var options = {
  5.         movement: {
  6.                 // The main wrapper.
  7.                 imgWrapper : {
  8.                         translation : {x: 10, y: 10, z: 30},
  9.                         rotation : {x: 0, y: -10, z: 0},
  10.                         reverseAnimation : {duration : 200, easing : 'easeOutQuad'}
  11.                 },
  12.                 // The SVG lines element.
  13.                 lines : {
  14.                         translation : {x: 10, y: 10, z: [0,70]},
  15.                         rotation : {x: 0, y: 0, z: -2},
  16.                         reverseAnimation : {duration : 2000, easing : 'easeOutExpo'}
  17.                 },
  18.                 // The caption/text element.
  19.                 caption : {
  20.                         rotation : {x: 0, y: 0, z: 2},
  21.                         reverseAnimation : {duration : 200, easing : 'easeOutQuad'}
  22.                 },
  23.                 // The overlay element.
  24.                 overlay : {
  25.                         translation : {x: 10, y: -10, z: 0},
  26.                         rotation : {x: 0, y: 0, z: 2},
  27.                         reverseAnimation : {duration : 2000, easing : 'easeOutExpo'}
  28.                 },
  29.                 // The shine element.
  30.                 shine : {
  31.                         translation : {x: 100, y: 100, z: 0},
  32.                         reverseAnimation : {duration : 200, easing : 'easeOutQuad'}
  33.                 }
  34.         }
  35. }
复制代码



鼠标悬停动态倾斜多重效果展示代码
  • qq喋喋以喋以喋喋xWC 刚刚下载了一个素材
  • 蝁噩噩噩 刚刚下载了一个素材
  • tomtop 刚刚下载了一个素材
  • Wmr 刚刚下载了一个素材
  • Andy66545 刚刚下载了一个素材
  • 2918 刚刚下载了一个素材
  • 西洲过客 刚刚下载了一个素材
  • 好朋 刚刚下载了一个素材
  • 拾到幸福的人 刚刚下载了一个素材
  • 有钱有钱变有钱 刚刚下载了一个素材
  • 墨迹111 刚刚下载了一个素材
  • MaskYS 刚刚下载了一个素材
  • qq明天会更好J0N 刚刚下载了一个素材
  • 半城烟沙。 刚刚下载了一个素材
  • 王烁巽 刚刚下载了一个素材
分享者:
分享者头像
素材网小编
热门素材推荐
HTML素材网,HTML5模板,网页特效 微信公众账号二维码 淘宝店铺地址二维码
Copyright©2024  素材8  Powered by 智伙伴科技
   鲁ICP备14029286号-5 鲁公网安备37060202001967号
返回顶部返回顶部
发布主题