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.残缺代码:
<!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