Home > Web Front-end > CSS Tutorial > In-depth understanding of how to use the filter attribute in CSS

In-depth understanding of how to use the filter attribute in CSS

yulia
Release: 2018-09-20 18:02:41
Original
3271 people have browsed it

This article only talks about how to use CSS filters. It is very detailed. Friends in need can refer to it. I hope it will be useful to you.

How to use CSS filters: filter:filtername(parameters) i.e. filter:filter name (parameters)

alpha: set the transparency level
blur: create a high-speed movement effect, That is, the blur effect
chroma: Make a special color transparent
DropShadow: Create a fixed shadow of the object
FlipH: Create a horizontal mirror image
FlipV: Create a vertical mirror image
glow: Add glow to nearby objects Outside the edge
gray: Grayscale the image
invert: Invert color
light: Create a light source on the object
mask: Create a transparent mask on the object
shadow: Create an offset Fixed shadow
wave: ripple effect
Xray: makes the object look like it is illuminated by x-rays

There are two specific application methods:

1. Define the CSS first , and then use predefined CSS on the required objects in the page. In fact, the syntax of these filters has been preset in the CSS settings dialog box. We only need to fill in the appropriate specific parameters.

2. Write CSS filter code directly on the HTML control element that supports CSS filter effects.

Alpha filter: When you hear this name, you may think that it is in Flash, and it seems that you have seen it in Photoshop. Yes, they do basically the same thing, that is, blend a target element with the background. You can specify numerical values ​​to control the degree of blending. In layman's terms, this "mixing with the background" is the transparency of an element.

Syntax: STYLE="filter: Alpha(Opacity=opacity, FinishOpacity=finishopacity, Style=style, StartX=startX, StartY=startY , FinishX=finishX, FinishY=finishY)"
Description:
Opacity: starting value, ranging from 0 to 100, 0 is transparent, 100 is the original image.
FinishOpacity: target value.
Style: 1 or 2 or 3
StartX: any value
StartY: any value
Example: filter:Alpha(Opacity="0″,FinishOpacity="75″,Style="2″ )

Blur filter: It is one of the CSS filters. Loading it on text can produce the effect of three-dimensional characters, which will bring great benefits to your use of three-dimensional characters as titles on web pages. It is convenient and reduces the weight of your web page; loading the Blur filter onto the image can make your image more colorful. Although the same effect can be achieved with image processing software, it is much more convenient to use the Blur filter. .

Syntax: STYLE="filter:Blur(Add = add, Direction = direction, Strength = strength)"
Description:
Add: Generally 1, or 0.
Direction: Angle, 0~315 degrees, step size is 45 degrees.
Strength: The value of effect growth, usually 5.
Example: filter:Blur(Add="1″,Direction="45″,Strength="5″)

Chroma filter: Set the color concentration of the object
Syntax: STYLE=" filter:Chroma(Color = color)"
Description: color: #rrggbb format, any.
Example: filter:Chroma(Color="#FFFFFF")

DropShadow filter: As the name suggests, it adds a shadow effect to the object. The actual effect is as if the original object leaves the page and a shadow of the object appears on the page. The working principle is to establish an offset and then add the color.
Syntax: STYLE="filter:DropShadow(Color=color, OffX=offX, OffY=offY, Positive=positive)"
Description: Color :#rrggbb format, any.
Offx: X-axis deviation value.
Offy: Y-axis offset value.
Positive: 1 or 0.
Example: filter:DropShadow(Color="#6699CC",OffX="5″,OffY="5″,Positive="1″)

FlipH filter: achieve horizontal inversion
Grammar: STYLE="filter:FlipH"
Example: filter:FlipH
FlipV filter: filter to achieve vertical inversion
Grammar: STYLE="filter:FlipV"
Example: filter: FlipV

Glow filter: After using the "glow" attribute on an object, the edge of the object will produce a glow-like effect
Syntax: STYLE="filter:Glow(Color=color, Strength= strength)"
Description:
Color: Luminous color.
Strength: Strength (0-100)
Example: filter:Glow(Color="#6699CC",Strength="5″)

Gray filter: Use the Gray filter to Turn a picture into a grayscale image

Syntax: STYLE="filter:Gray"
Example: filter:Gray

Invert filter: As the name suggests, invert the object
Syntax: STYLE="filter:Invert"
Example: filter:Invert

Mask filter: Use the "MASK" attribute to create a film covering the surface of the object. The effect is like wearing a colored Glasses see objects the same
Syntax: STYLE="filter:Mask(Color=color)"
Example: filter:Mask (Color="#FFFFE0″)

Shadow filter: Use "Shadow "Attributes can establish the projection of an object in the specified direction, COLOR is the projection color, and DIRECTION sets the direction of the projection. Where 0 degrees represents vertical upward, and then every 45 degrees is a unit. Its default value is 270 degrees to the left.

Syntax: filter:Shadow(Color=color, Direction=direction)
Description:
Color:#rrggbb format.
Direction: Angle, 0-315 degrees, step size is 45 degrees.
Example: filter:Shadow (Color="#6699CC", Direction="135″)

Wave filter: You may be able to think of its effect by looking at its name. As you think, its function is to distort the object in a vertical waveform style, thereby producing a special effect
Syntax: filter: Wave(Add=add, Freq=freq, LightStrength=strength, Phase=phase, Strength=strength)
Description:
Add: Generally 1, or 0.
Freq: deformation value.
LightStrength: Deformation percentage.
Phase: Angle deformation percentage.
Strength: Deformation strength.
Example: filter: wave(Add="0″, Phase="4″, Freq="5″, LightStrength="5″, Strength="2″)

Xray filter: only Display the outline of an object
Syntax: STYLE="filter:Xray"
Example: filter:Xray

The above is the detailed content of In-depth understanding of how to use the filter attribute in CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template