blob: fe613ed14822a368f36684e4536f40ecc76d3d6d (
plain)
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
|
---
title: backdrop-filter
slug: Web/CSS/backdrop-filter
translation_of: Web/CSS/backdrop-filter
---
<div>{{CSSRef}}{{SeeCompatTable}}</div>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS">CSS</a> свойство <strong><code>backdrop-filter</code></strong> позволяет вам использовать визуальные эффекты - такие как размытие или смещение цвета фона - за элементом. Так как это применяется ко всему <em>за</em> элементом, чтобы увидеть эффект, вы должны сделать элемент или его фон по крайней мере частично прозрачными.</p>
<pre class="brush: css no-line-numbers language-css"><code class="language-css"><span class="comment token">/* Keyword value */</span></code><code class="language-css">
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> none<span class="punctuation token">;</span>
<span class="comment token">/* фильтр URL в SVG */</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="token url">url(commonfilters.svg#filter)</span><span class="punctuation token">;</span>
<span class="comment token">/* значения <filter-function> */</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">blur</span><span class="punctuation token">(</span><span class="number token">2</span><span class="token unit">px</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">brightness</span><span class="punctuation token">(</span><span class="number token">60</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">contrast</span><span class="punctuation token">(</span><span class="number token">40</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">drop-shadow</span><span class="punctuation token">(</span><span class="number token">4</span><span class="token unit">px</span> <span class="number token">4</span><span class="token unit">px</span> <span class="number token">10</span><span class="token unit">px</span> blue<span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">grayscale</span><span class="punctuation token">(</span><span class="number token">30</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">hue-rotate</span><span class="punctuation token">(</span><span class="number token">120</span><span class="token unit">deg</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">invert</span><span class="punctuation token">(</span><span class="number token">70</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">opacity</span><span class="punctuation token">(</span><span class="number token">20</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">sepia</span><span class="punctuation token">(</span><span class="number token">90</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">saturate</span><span class="punctuation token">(</span><span class="number token">80</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="comment token">/* Несколько фильтров */</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="token url">url(filters.svg#filter)</span> <span class="function token">blur</span><span class="punctuation token">(</span><span class="number token">4</span><span class="token unit">px</span><span class="punctuation token">)</span> <span class="function token">saturate</span><span class="punctuation token">(</span><span class="number token">150</span><span class="token unit">%</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="comment token">/* Глобальные значения */</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> inherit<span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> initial<span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> unset<span class="punctuation token">;</span></code></pre>
<p>{{cssinfo}}</p>
<h2 id="Синтаксис">Синтаксис</h2>
<h3 id="Значения">Значения</h3>
<dl>
<dt><code>none</code></dt>
<dd>Фильтр отключён для фона</dd>
<dt><code><filter-function-list></code></dt>
<dd>Перечень фильтров, разделённых пробелами функций {{cssxref("<filter-function>")}} или <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/filter">SVG фильтра</a>, которые применены для фона.</dd>
</dl>
<h3 id="Формальный_синтаксис">Формальный синтаксис</h3>
{{csssyntax}}
<h2 id="Примеры">Примеры</h2>
<h3 id="CSS">CSS</h3>
<pre class="brush: css line-numbers language-css"><code class="language-css"><span class="selector token"><span class="class token">.box</span></span> <span class="punctuation token">{</span>
<span class="property token">background-color</span><span class="punctuation token">:</span> <span class="function token">rgba</span><span class="punctuation token">(</span><span class="number token">255</span><span class="punctuation token">,</span> <span class="number token">255</span><span class="punctuation token">,</span> <span class="number token">255</span><span class="punctuation token">,</span> <span class="number token">0.3</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">border-radius</span><span class="punctuation token">:</span> <span class="number token">5</span><span class="token unit">px</span><span class="punctuation token">;</span>
<span class="property token">font-family</span><span class="punctuation token">:</span> sans-serif<span class="punctuation token">;</span>
<span class="property token">text-align</span><span class="punctuation token">:</span> center<span class="punctuation token">;</span>
<span class="property token">line-height</span><span class="punctuation token">:</span> <span class="number token">1</span><span class="punctuation token">;</span>
<span class="property token">-webkit-backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">blur</span><span class="punctuation token">(</span><span class="number token">10</span><span class="token unit">px</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">backdrop-filter</span><span class="punctuation token">:</span> <span class="function token">blur</span><span class="punctuation token">(</span><span class="number token">10</span><span class="token unit">px</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="property token">max-width</span><span class="punctuation token">:</span> <span class="number token">50</span><span class="token unit">%</span><span class="punctuation token">;</span>
<span class="property token">max-height</span><span class="punctuation token">:</span> <span class="number token">50</span><span class="token unit">%</span><span class="punctuation token">;</span>
<span class="property token">padding</span><span class="punctuation token">:</span> <span class="number token">20</span><span class="token unit">px</span> <span class="number token">40</span><span class="token unit">px</span><span class="punctuation token">;</span>
<span class="punctuation token">}</span>
<span class="selector token">html,
body</span> <span class="punctuation token">{</span>
<span class="property token">height</span><span class="punctuation token">:</span> <span class="number token">100</span><span class="token unit">%</span><span class="punctuation token">;</span>
<span class="property token">width</span><span class="punctuation token">:</span> <span class="number token">100</span><span class="token unit">%</span><span class="punctuation token">;</span>
<span class="punctuation token">}</span>
<span class="selector token">body</span> <span class="punctuation token">{</span>
<span class="property token">background-image</span><span class="punctuation token">:</span> <span class="token url">url('https://lorempixel.com/400/200/')</span><span class="punctuation token">;</span>
<span class="property token">background-position</span><span class="punctuation token">:</span> center center<span class="punctuation token">;</span>
<span class="property token">background-repeat</span><span class="punctuation token">:</span> no-repeat<span class="punctuation token">;</span>
<span class="property token">background-size</span><span class="punctuation token">:</span> cover<span class="punctuation token">;</span>
<span class="punctuation token">}</span>
<span class="selector token"><span class="class token">.container</span></span> <span class="punctuation token">{</span>
<span class="property token">align-items</span><span class="punctuation token">:</span> center<span class="punctuation token">;</span>
<span class="property token">display</span><span class="punctuation token">:</span> flex<span class="punctuation token">;</span>
<span class="property token">justify-content</span><span class="punctuation token">:</span> center<span class="punctuation token">;</span>
<span class="property token">height</span><span class="punctuation token">:</span> <span class="number token">100</span><span class="token unit">%</span><span class="punctuation token">;</span>
<span class="property token">width</span><span class="punctuation token">:</span> <span class="number token">10</span><span class="punctuation token">}</span></code></pre>
<h3 id="HTML">HTML</h3>
<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token"><</span>div</span> <span class="attr-name token">class</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>container<span class="punctuation token">"</span></span><span class="punctuation token">></span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token"><</span>div</span> <span class="attr-name token">class</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>box<span class="punctuation token">"</span></span><span class="punctuation token">></span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token"><</span>p</span><span class="punctuation token">></span></span>backdrop-filter: blur(10px)<span class="tag token"><span class="tag token"><span class="punctuation token"></</span>p</span><span class="punctuation token">></span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token"></</span>div</span><span class="punctuation token">></span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token"></</span>div</span><span class="punctuation token">></span></span></code></pre>
<h3 id="Результат">Результат</h3>
<p>{{EmbedLiveSample("Примеры", 600, 400)}}</p>
<h2 id="Спецификации">Спецификации</h2>
{{Specifications}}
<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
<p>{{Compat}}</p>
<h2 id="Смотрите_также">Смотрите также</h2>
<ul>
<li>{{cssxref("filter")}}</li>
<li><a href="http://product.voxmedia.com/til/2015/2/17/8053347/css-ios-transparency-with-webkit-backdrop-filter">Building iOS-like transparency effects in CSS with backdrop-filter</a></li>
</ul>
|