Home Web Front-end CSS Tutorial CSS Tutorial (7) Filter

CSS Tutorial (7) Filter

Apr 01, 2017 pm 02:22 PM
css Tutorial filter

CSS provides some built-in multimedia filter effects. This technology can be used to add visual filters and transformation effects to a standard HTML element, such as images, text containers, and other objects. Dreamweaver4 provides 16 filters to choose from, as shown below:

Next, let’s take a look at how to use these CSS filters conveniently in Dreamweaver4.

Create a custom style ".filter", select the Alpha filter in the Filter drop-down box, we will "Alpha(Opacity=?, FinishOpacity=?, style=?, StartX=?, StartY=? , FinishX=?, FinishY=?)"'s Opacity parameter is set to 50, and all subsequent parameters are deleted, as shown below:

After pressing OK, a custom style of ".filter" is created. We Apply this style to an image and the image will be semi-transparent. If you apply this style to a table, the table will also become semi-transparent. Note that all filter effects can only be seen in the browser. The following is the original code:



Note: In this example we did not use the following parameters, only the Opacity parameter, so Delete other parameters.

Let’s explain the effects and parameters of each filter:

1. Alpha: Set transparency

Alpha(Opacity=?, FinishOpacity=?, style=? , StartX=?, StartY=?, FinishX=?, FinishY=?)

Opacity: Transparency level, range is 0-100, 0 represents completely transparent, 100 represents completely opaque.

FinishOpacity: When setting the transparency effect of the gradient, it is used to specify the transparency at the end, and the range is also 0 to 100.

style: Set the gradient transparent style. A value of 0 represents a uniform shape, 1 represents a linear shape, 2 represents a radial shape, and 3 represents a rectangle.

StartX and StartY: represent the starting X and Y coordinates of the gradient transparency effect.

FinishX and FinishY: represent the X and Y coordinates of the end of the gradient transparency effect.

2. BlendTrans: The fade-in and fade-out effect between images

BlendTrans(Duration=?)

Duration: The fade-in or fade-out time.

Note: This filter must be used with JS to create a picture sequence to create effects between pictures.

3. Blru: Create a blur effect

Blur(Add=?, Direction=?, Strength=?)

Add: Whether to blur in one direction, this parameter is a Boolean value, true (not 0) or false (0).

Direction: Set the direction of the blur, where 0 degrees represents vertical upward, and then every 45 degrees is a unit.

Strength: represents the blurred pixel value.

4. Chroma: Set the specified color to be transparent

Chroma(Color=?)

Color: Refers to the color to be set to transparent.

5. DropShadow: Create a shadow effect

DropShadow(Color=?, OffX=?, OffY=?, Positive=?)

Color: Specify the color of the shadow.

OffX: Specifies the horizontal offset of the shadow relative to the element, an integer.

OffY: Specifies the vertical offset of the shadow relative to the element, an integer.

Positive: It is a Boolean value. When the value is true (non-0), it means establishing an outer shadow; when it is false (0), it means establishing an inner shadow.

6. FlipH: Flip the element horizontally

7. FlipV: Flip the element vertically

8. Glow: Create an outer glow effect

Glow(Color=?, Strength=?)

Color: specifies the color of light. Strength: The intensity of the light, which can be any integer between 1 and 255. The larger the number, the greater the range of the light.

9. Gray: Remove the color of the image and display it as a black and white image

10. Invert: Invert the color of the image, producing a film-like effect

11. Light: The effect of placing a light source, which can be used to simulate the projection effect of a light source on an object.

Note: This effect requires JS to set the position and intensity of the light.

12. Mask: Create a transparent mask

Mask(Color=?)

Color: Set the background color to make the part of the object covering the background transparent.

13. RevealTrans: Create switching effect

RevealTrans(Duration=?, Transition=?)

Duration: is the switching time, in seconds.

Transtition: It is the switching method and can be set from 0 to 23.

Note: If you want to switch between pages, you can add a line of code in the area: . If the element is used in the page, it must be used with JS.

14. Shadow: Create another shadow effect

Shadow(Color=?, Direction=?)

Color: refers to the color of the shadow.

Direction: Sets the direction of the projection. 0 degrees means vertically upward, and every 45 degrees is a unit.

15. Wave: Ripple effect

Wave(Add=?, Freq=?, LightStrength=?, Phase=?, Strength=?)

Add: Indicates whether Display the original object, 0 means not to display, non-0 means to display the original object.

Freq: Set the number of fluctuations.

LightStrength: Set the light intensity of the wave effect, from 0 to 100. 0 represents the weakest, and 100 represents the strongest.

Phase: The initial phase angle of the wave. Percent value from 0 to 100. (For example: 25 is equivalent to 90 degrees, and 50 is equivalent to 180 degrees.)

Strength: Set the amplitude of the wave sway.

16. Elements without area such as text and paragraphs cannot use CSS filters. For such elements, we can set the Height and Width styles or coordinates of the elements to achieve this.

Look at the example below. We create a shadow effect (dropshadow) on a line of text, create a new custom style.shadow, and select "DropShadow(Color=?, OffX=?, OffY=?, in the filter drop-down box). Positive=?)", we set it to "DropShadow(Color=999999, OffX=2, OffY=2, Positive=1)". Then when we apply the defined style to the page, we find that the text in the table has a shadow, but the text in the paragraph has no shadow. Click the Edit Style Sheet button in the CSS styles panel and add the Hight attribute to the style:

In order not to affect the height of the original object, the height we set cannot exceed the height of the font itself. After OK, you can see in the browser that the text in the paragraph also has a shadow.

The above is the detailed content of CSS Tutorial (7) Filter. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

See all articles