-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathliquid-glass-effect.html
More file actions
285 lines (243 loc) · 11.2 KB
/
liquid-glass-effect.html
File metadata and controls
285 lines (243 loc) · 11.2 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
Эффект Liquid Glass для шейпа Zero-блока Тильды
<!-- ********************************************************************** -->
<!-- Эффект Liquid Glass для шейпа Zero-блока Тильды -->
<!-- ********************************************************************** -->
<!-- Создает реалистичный эффект жидкого стекла с размытием фона и -->
<!-- полупрозрачностью. Применяется к любым элементам через CSS-класс. -->
<!-- Обратите внимаение что border-radius у шейпа -->
<!-- и «--uc-lg-border-radius» должны совпадать -->
<!-- ********************************************************************** -->
<style>
/* Основной контейнер для Liquid Glass */
.uc-liquid-glass {
/* CSS переменные с фоллбеками */
--uc-lg-border-radius: 20px;
--uc-lg-blur-intensity: 3px;
--uc-lg-tint-opacity: 0.25;
--uc-lg-shadow-opacity: 0.2;
--uc-lg-shine-intensity: 0.5;
--uc-lg-fallback-bg: rgba(255, 255, 255, 0.8); /* Фоллбек для старых браузеров */
position: relative !important;
overflow: hidden !important;
border-radius: var(--uc-lg-border-radius, 20px) !important;
/* Фоллбек фон для браузеров без backdrop-filter */
background: var(--uc-lg-fallback-bg) !important;
/* Тень контейнера */
box-shadow:
0 6px 6px rgba(0, 0, 0, var(--uc-lg-shadow-opacity, 0.2)),
0 0 20px rgba(0, 0, 0, calc(var(--uc-lg-shadow-opacity, 0.2) * 0.5)) !important;
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2) !important;
/* Фоллбек переходы для IE */
-ms-transition: all 0.4s ease !important;
-webkit-transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2) !important;
-moz-transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2) !important;
-o-transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2) !important;
}
/* Фоллбек для браузеров без поддержки backdrop-filter */
.uc-liquid-glass.no-backdrop-filter {
background: rgba(255, 255, 255, 0.9) !important;
border: 1px solid rgba(255, 255, 255, 0.3) !important;
}
/* Слой размытия фона — только для поддерживающих браузеров */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
.uc-liquid-glass {
background: rgba(255, 255, 255, var(--uc-lg-tint-opacity, 0.25)) !important;
}
.uc-liquid-glass::before {
content: '' !important;
position: absolute !important;
inset: 0 !important;
z-index: 0 !important;
/* Кроссбраузерный backdrop-filter */
-webkit-backdrop-filter: blur(var(--uc-lg-blur-intensity, 3px)) !important;
backdrop-filter: blur(var(--uc-lg-blur-intensity, 3px)) !important;
filter: url(#uc-glass-distortion) !important;
border-radius: inherit !important;
pointer-events: none !important;
}
.uc-liquid-glass::after {
content: '' !important;
position: absolute !important;
inset: 0 !important;
z-index: 1 !important;
background: rgba(255, 255, 255, var(--uc-lg-tint-opacity, 0.25)) !important;
border-radius: inherit !important;
pointer-events: none !important;
}
}
/* Слой с бликами */
.uc-liquid-glass .tn-atom {
position: relative !important;
z-index: 3 !important;
background: transparent !important;
}
.uc-liquid-glass .tn-atom::before {
content: '' !important;
position: absolute !important;
inset: 0 !important;
z-index: 2 !important;
box-shadow:
inset 2px 2px 1px 0 rgba(255, 255, 255, var(--uc-lg-shine-intensity, 0.5)),
inset -1px -1px 1px 1px rgba(255, 255, 255, var(--uc-lg-shine-intensity, 0.5)) !important;
border-radius: inherit !important;
pointer-events: none !important;
}
/* Интерактивные эффекты — кроссбраузерные */
/*
.uc-liquid-glass:hover {
transform: translateY(-2px) !important;
-webkit-transform: translateY(-2px) !important;
-moz-transform: translateY(-2px) !important;
-ms-transform: translateY(-2px) !important;
-o-transform: translateY(-2px) !important;
box-shadow:
0 8px 12px rgba(0, 0, 0, calc(var(--uc-lg-shadow-opacity, 0.2) * 1.2)),
0 0 30px rgba(0, 0, 0, calc(var(--uc-lg-shadow-opacity, 0.2) * 0.7)) !important;
}
.uc-liquid-glass:active {
transform: translateY(0px) scale(0.98) !important;
-webkit-transform: translateY(0px) scale(0.98) !important;
-moz-transform: translateY(0px) scale(0.98) !important;
-ms-transform: translateY(0px) scale(0.98) !important;
-o-transform: translateY(0px) scale(0.98) !important;
}
*/
/* Фоллбек hover эффекты для старых браузеров без calc() */
/*
.no-css-calc .uc-liquid-glass:hover {
box-shadow:
0 8px 12px rgba(0, 0, 0, 0.24),
0 0 30px rgba(0, 0, 0, 0.14) !important;
}
*/
/* Фоллбек для браузеров без transform */
/*
.no-transforms .uc-liquid-glass:hover {
margin-top: -2px !important;
}
.no-transforms .uc-liquid-glass:active {
margin-top: 0px !important;
transform: none !important;
}
*/
/* SVG фильтр */
.uc-svg-filter {
position: absolute !important;
width: 0 !important;
height: 0 !important;
overflow: hidden !important;
pointer-events: none !important;
}
</style>
<!-- JavaScript для детекции поддержки -->
<script>
(function() {
'use strict';
// Функция проверки поддержки backdrop-filter
function supportsBackdropFilter() {
const testElement = document.createElement('div');
testElement.style.cssText = '-webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);';
return testElement.style.backdropFilter !== '' || testElement.style.webkitBackdropFilter !== '';
}
// Функция проверки поддержки SVG фильтров
function supportsSVGFilters() {
try {
return typeof SVGFEGaussianBlurElement !== 'undefined' &&
typeof document.createElementNS('http://www.w3.org/2000/svg', 'feGaussianBlur').setStdDeviation === 'function';
} catch (e) {
return false;
}
}
// Функция проверки поддержки CSS переменных
function supportsCSSVariables() {
return window.CSS && CSS.supports && CSS.supports('color', 'var(--fake-var)');
}
// Функция проверки поддержки calc()
function supportsCalc() {
const testElement = document.createElement('div');
testElement.style.cssText = 'width: calc(1px + 1px);';
return testElement.style.width === 'calc(2px)' || testElement.style.width === '2px';
}
// Функция проверки поддержки transforms
function supportsTransforms() {
const testElement = document.createElement('div');
testElement.style.cssText = 'transform: translateX(1px);';
return testElement.style.transform !== '' ||
testElement.style.webkitTransform !== '' ||
testElement.style.mozTransform !== '' ||
testElement.style.msTransform !== '';
}
// Ждем загрузки DOM
function init() {
const elements = document.querySelectorAll('.uc-liquid-glass');
const documentElement = document.documentElement;
// Добавляем классы-детекторы на html
if (!supportsBackdropFilter()) {
elements.forEach(function(el) {
el.classList.add('no-backdrop-filter');
});
}
if (!supportsCalc()) {
documentElement.classList.add('no-css-calc');
}
if (!supportsTransforms()) {
documentElement.classList.add('no-transforms');
}
if (!supportsSVGFilters()) {
// Убираем SVG фильтр если не поддерживается
const svgFilter = document.querySelector('.uc-svg-filter');
if (svgFilter) {
svgFilter.style.display = 'none';
}
}
// Фоллбек для CSS переменных (для IE)
if (!supportsCSSVariables()) {
elements.forEach(function(el) {
el.style.borderRadius = '20px';
el.style.background = 'rgba(255, 255, 255, 0.9)';
el.style.boxShadow = '0 6px 6px rgba(0, 0, 0, 0.2), 0 0 20px rgba(0, 0, 0, 0.1)';
// Добавляем hover эффекты через JS для IE
/*
el.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-2px)';
this.style.boxShadow = '0 8px 12px rgba(0, 0, 0, 0.24), 0 0 30px rgba(0, 0, 0, 0.14)';
});
el.addEventListener('mouseleave', function() {
this.style.transform = '';
this.style.boxShadow = '0 6px 6px rgba(0, 0, 0, 0.2), 0 0 20px rgba(0, 0, 0, 0.1)';
});
el.addEventListener('mousedown', function() {
this.style.transform = 'translateY(0px) scale(0.98)';
});
el.addEventListener('mouseup', function() {
this.style.transform = 'translateY(-2px)';
});
*/
});
}
}
// Запуск после загрузки DOM
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
</script>
<!-- SVG фильтр -->
<svg class="uc-svg-filter">
<filter id="uc-glass-distortion" x="0%" y="0%" width="100%" height="100%" filterUnits="objectBoundingBox">
<feTurbulence type="fractalNoise" baseFrequency="0.01 0.01" numOctaves="1" seed="5" result="turbulence" />
<feComponentTransfer in="turbulence" result="mapped">
<feFuncR type="gamma" amplitude="1" exponent="10" offset="0.5" />
<feFuncG type="gamma" amplitude="0" exponent="1" offset="0" />
<feFuncB type="gamma" amplitude="0" exponent="1" offset="0.5" />
</feComponentTransfer>
<feGaussianBlur in="turbulence" stdDeviation="3" result="softMap" />
<feSpecularLighting in="softMap" surfaceScale="5" specularConstant="1" specularExponent="100" lighting-color="white" result="specLight">
<fePointLight x="-200" y="-200" z="300" />
</feSpecularLighting>
<feComposite in="specLight" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litImage" />
<feDisplacementMap in="SourceGraphic" in2="softMap" scale="150" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>