افکت زیبا کج شدن برای تصاویر - Tilt Hover Effects
کد HTML :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<section class="content content--c1">
<a href="#" class="tilter tilter--1">
<figure class="tilter__figure">
<img class="tilter__image" src="1.jpg" alt="img01" />
<div class="tilter__deco tilter__deco--shine"><div></div></div>
<figcaption class="tilter__caption">
<h3 class="tilter__title">Tanya Bondesta</h3>
<p class="tilter__description">Toronto</p>
</figcaption>
<svg class="tilter__deco tilter__deco--lines" viewBox="0 0 300 415">
<path d="M20.5,20.5h260v375h-260V20.5z" />
</svg>
</figure>
</a>
</section>
|
کد CSS :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
*, *::after, *::before { -webkit-box-sizing: border-box; box-sizing: border-box; }
.tilter { display: block; position: relative; width: 300px; height: 415px; margin: 1.5em auto; color: #fff; perspective: 1000px; }
.tilter * { pointer-events: none; }
.tilter:hover, .tilter:focus { color: #fff; outline: none; }
/* .tilter__figure, .tilter__deco, .tilter__caption { will-change: transform; }*/
.tilter__figure, .tilter__image { margin: ; width: 100%; height: 100%; display: block; }
.tilter__figure > * { transform: translateZ(0px); /* Force correct stacking order */ }
.smooth .tilter__figure, .smooth .tilter__deco--overlay, .smooth .tilter__deco--lines, .smooth .tilter__deco--shine div, .smooth .tilter__caption { transition: transform 0.2s ease-out; }
.tilter__figure { position: relative; }
.tilter__figure::before { content: ''; position: absolute; width: 90%; height: 90%; top: 5%; left: 5%; box-shadow: 30px 20px rgba(35,32,39,0.5); }
.tilter__deco { position: absolute; top: ; left: ; width: 100%; height: 100%; overflow: hidden; }
.tilter__deco--overlay { background-image: linear-gradient(45deg, rgba(226, 60, 99, 0.4), rgba(145, 58, 252, 0.4), rgba(16, 11, 192, 0.4)); }
.tilter__deco--shine div { position: absolute; width: 200%; height: 200%; top: -50%; left: -50%; background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.5) 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%); }
.tilter__deco--lines { fill: none; stroke: #fff; stroke-width: 1.5px; }
.tilter__caption { position: absolute; bottom: ; width: 100%; padding: 4em; }
.tilter__title { margin: ; font-weight: normal; font-size: 2.5em; font-family: 'Abril Fatface', serif; line-height: 1; }
.tilter__description { margin: 1em ; font-size: 0.85em; letter-spacing: 0.15em; }
/* Individual styles */
/* Example 7 (different line) */ .tilter--7 .tilter__deco--overlay { background-image: linear-gradient(45deg, rgba(93, 203, 106, 0.48), rgba(59, 239, 255, 0.58)); }
.tilter--7 .tilter__deco--lines { stroke-width: 20px; transform: scale3d(0.9,0.9,1); opacity: ; transition: transform 0.3s, opacity 0.3s; }
.tilter--7:hover .tilter__deco--lines { opacity: 1; transform: scale3d(1,1,1); }
.tilter--7 .tilter__figure::before { box-shadow: none; } |
کد JS:
در این مطلب از anime.js استفاده شده است.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
new TiltFx(document.querySelector('a.tilter'), {
movement: {
imgWrapper : {
translation : {x: 5, y: 5, z: },
reverseAnimation : {duration : 800, easing : 'easeOutQuart'}
},
caption : {
translation : {x: 10, y: 10, z: [,50]},
reverseAnimation : {duration : 1000, easing : 'easeOutQuart'}
},
shine : {
translation : {x: 50, y: 50, z: },
reverseAnimation : {duration : 800, easing : 'easeOutQuart'}
}
}
});
|
امیدوارم خوشتون بیاد.
- ۹۶/۱۲/۱۶