我是靠谱客的博主 温婉小土豆,这篇文章主要介绍css的filter属性,现在分享给大家,希望可以做个参考。

1.官方文档

注意:Internet Explorer 不支持 filter 属性
https://www.runoob.com/cssref/css3-pr-filter.html

2属性

2.1blur

给图像设置高斯模糊。"radius"一值设定高斯函数的标准差,或者是屏幕上以多少像素融在一起, 所以值越大越模糊;
在这里插入图片描述

2.2brightness

给图片应用一种线性乘法,使其看起来更亮或更暗。如果值是0%,图像会全黑。值是100%,则图像无变化。其他的值对应线性乘数效果。值超过100%也是可以的,图像会比原来更亮。如果没有设定值,默认是1
在这里插入图片描述

2.3contrast

调整图像的对比度。值是0%的话,图像会全黑。值是100%,图像不变。值可以超过100%,意味着会运用更低的对比。若没有设置值,默认是1。

在这里插入图片描述

2.4grayscale

在这里插入图片描述

2.5hue-rotate

给图像应用色相旋转。"angle"一值设定图像会被调整的色环角度值。值为0deg,则图像无变化。若值未设置,默认值是0deg。该值虽然没有最大值,超过360deg的值相当于又绕一圈。
在这里插入图片描述

2.6invert

反转输入图像。值定义转换的比例。100%的价值是完全反转。值为0%则图像无变化。值在0%和100%之间,则是效果的线性乘子。 若值未设置,值默认是0。

在这里插入图片描述

2.7opacity:

转化图像的透明程度。值定义转换的比例。值为0%则是完全透明,值为100%则图像无变化。值在0%和100%之间,则是效果的线性乘子,也相当于图像样本乘以数量。 若值未设置,值默认是1。该函数与已有的opacity属性很相似,不同之处在于通过filter,一些浏览器为了提升性能会提供硬件加速。
在这里插入图片描述

2.8saturate:

转换图像饱和度。值定义转换的比例。值为0%则是完全不饱和,值为100%则图像无变化。其他值,则是效果的线性乘子。超过100%的值是允许的,则有更高的饱和度。 若值未设置,值默认是1。
在这里插入图片描述

2.9sepia:

将图像转换为深褐色。值定义转换的比例。值为100%则完全是深褐色的,值为0%图像无变化。值在0%到100%之间,则是效果的线性乘子。若未设置,值默认是0;
在这里插入图片描述

2.10drop-shadow:

给图像设置一个阴影效果。阴影是合成在图像下面,可以有模糊度的,可以以特定颜色画出的遮罩图的偏移版本。
在这里插入图片描述

3.完整代码:

复制代码
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
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <style> .mauto{ width: 400px; margin: 20px auto; text-align: center; color: #999; } img { width: 200px; height: 200px; margin: 20px; } .text{ position: relative; transform: perspective(0.5em) rotateX(10deg); transform-origin: bottom left; background: lightblue; display: inline-block; margin-bottom: 20px; font-size: 40px; } .text::after { display: inline-block; content: 'css的filter属性'; transform: perspective(0.5em) rotateX(-10deg); transform-origin: bottom left; } .blur { -webkit-filter: blur(4px); filter: blur(4px); } .brightness { -webkit-filter: brightness(0.30); filter: brightness(0.30); } .contrast { -webkit-filter: contrast(60%); filter: contrast(60%); } .grayscale { -webkit-filter: grayscale(100%); filter: grayscale(100%); } .huerotate { -webkit-filter: hue-rotate(20deg); filter: hue-rotate(20deg); } .invert { -webkit-filter: invert(30%); filter: invert(30%); } .opacity { -webkit-filter: opacity(30%); filter: opacity(30%); } .saturate { -webkit-filter: saturate(2); filter: saturate(2); } .sepia { -webkit-filter: sepia(80%); filter: sepia(80%); } .shadow { -webkit-filter: drop-shadow(8px 8px 10px #00); filter: drop-shadow(8px 8px 10px #000); } </style> <body> <section class="mauto"> <div class="text"></div> </section> <section class="mauto"> <p><strong>注意:</strong> Internet Explorer 不支持 filter 属性。</p> </section> <section class="mauto"> <p><strong>blur:</strong>给图像设置高斯模糊。"radius"一值设定高斯函数的标准差,或者是屏幕上以多少像素融在一起, 所以值越大越模糊;</p> <img class="blur" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple" > </section> <section class="mauto"> <p><strong>brightness:</strong>给图片应用一种线性乘法,使其看起来更亮或更暗。如果值是0%,图像会全黑。值是100%,则图像无变化。其他的值对应线性乘数效果。值超过100%也是可以的,图像会比原来更亮。如果没有设定值,默认是1</p> <img class="brightness" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple"> </section> <section class="mauto"> <p><strong>contrast:</strong>调整图像的对比度。值是0%的话,图像会全黑。值是100%,图像不变。值可以超过100%,意味着会运用更低的对比。若没有设置值,默认是1。</p> <img class="contrast" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple" > </section> <section class="mauto"> <p><strong>grayscale:</strong>将图像转换为灰度图像。值定义转换的比例。值为100%则完全转为灰度图像,值为0%图像无变化。值在0%到100%之间,则是效果的线性乘子。若未设置,值默认是0;</p> <img class="grayscale" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple"> </section> <section class="mauto"> <p><strong>hue-rotate:</strong>给图像应用色相旋转。"angle"一值设定图像会被调整的色环角度值。值为0deg,则图像无变化。若值未设置,默认值是0deg。该值虽然没有最大值,超过360deg的值相当于又绕一圈。</p> <img class="huerotate" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple"> </section> <section class="mauto"> <p><strong>invert:</strong>反转输入图像。值定义转换的比例。100%的价值是完全反转。值为0%则图像无变化。值在0%和100%之间,则是效果的线性乘子。 若值未设置,值默认是0。</p> <img class="invert" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple" > </section> <section class="mauto"> <p><strong>opacity:</strong>转化图像的透明程度。值定义转换的比例。值为0%则是完全透明,值为100%则图像无变化。值在0%和100%之间,则是效果的线性乘子,也相当于图像样本乘以数量。 若值未设置,值默认是1。该函数与已有的opacity属性很相似,不同之处在于通过filter,一些浏览器为了提升性能会提供硬件加速。</p> <img class="opacity" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple" > </section> <section class="mauto"> <p><strong>saturate:</strong>转换图像饱和度。值定义转换的比例。值为0%则是完全不饱和,值为100%则图像无变化。其他值,则是效果的线性乘子。超过100%的值是允许的,则有更高的饱和度。 若值未设置,值默认是1。</p> <img class="saturate" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple" > </section> <section class="mauto"> <p><strong>sepia:</strong>将图像转换为深褐色。值定义转换的比例。值为100%则完全是深褐色的,值为0%图像无变化。值在0%到100%之间,则是效果的线性乘子。若未设置,值默认是0;</p> <img class="sepia" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple" > </section> <section class="mauto"> <p><strong>drop-shadow:</strong>给图像设置一个阴影效果。阴影是合成在图像下面,可以有模糊度的,可以以特定颜色画出的遮罩图的偏移版本。</p> <img class="shadow" src="https://i.postimg.cc/mgsKJGLw/susu1.jpg" alt="Pineapple"> </section> </body> </html>

4.更多代码

https://gitee.com/susuhhhhhh/css_demos

最后

以上就是温婉小土豆最近收集整理的关于css的filter属性的全部内容,更多相关css内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(94)

评论列表共有 0 条评论

立即
投稿
返回
顶部