Home Web Front-end CSS Tutorial Clever use of CSS MASK filter_Basic tutorial

Clever use of CSS MASK filter_Basic tutorial

May 16, 2016 pm 12:08 PM

The Mask filter can create a rectangular mask for the HTML element object on the web page. What is a mask? If you have used masks in Flash, you will know that it is like that. In fact, you can also understand masking in this way, which is equivalent to covering the object with a piece of colored cloth, but the content is dug out. If you still don’t understand, just look at the picture below and let me explain it to you in detail.
Clever use of CSS MASK filter_Basic tutorial
Figure 1 Mask filter effect 1

Use such a dark color in the mask filter above , mainly so that you can clearly see the effect. Let's take a look at the parameters of the mask filter: It has only one parameter Color, which is the color value of the mask in the format of #RRGGBB. You just need to choose a suitable color for it in DW3. For example, the mask filter code above is: .mask1 { filter:mask(color=#00ff00) }. In the following example, you will see, In fact, the color of the filter is not the main thing, the key is the color of the background.
Next we use the mask filter to create several special effects:
1. Colorful text
Clever use of CSS MASK filter_Basic tutorial
Figure 2 mask Filter Effect 2

How about the above effect? ​​It’s not bad! It's a bit like an image, isn't it? This is the effect of the mask filter. A white filter is used here, and its code is: .mask1 { filter:mask(color=#ffffff) }. The colorful text color is actually the color of the background. The production method is also very simple, just insert a 1*1 table, add a multi-colored background to the table, enter text in the table, load a mask filter to the cell, and you are done. Not difficult, right? !
2. Searchlight animation effect
The following searchlight effect requires a lot of effort to use Flash, but I never thought it could be done using CSS filters! Since the searchlight effect is dynamic, I can only capture two process pictures for you to see. If you want to see the dynamic effect, then you can make one according to what I said or go to my house (http://fym888.go.163.com) look.
Clever use of CSS MASK filter_Basic tutorial
Figure 3 Searchlight animation effect 1
Clever use of CSS MASK filter_Basic tutorial
Figure 4 Searchlight animation effect 2

Here is the production method:
This effect is a little more complicated than the above example, but it only requires a few more mouse clicks.
1. Insert a layer, which I call the "parent layer". This layer is used to place the content (text or pictures) to be displayed. Insert a layer on top of this layer, which I call a sublayer, and it's mainly used to create a masking effect.
2. Set the display window on the property panel of the parent layer, that is, set the "Clip" attribute of the layer. In this attribute, relative coordinates are used, where: L and T are the coordinates of the upper left corner; R and B is the coordinate of the lower right corner. Subsequent sublayers will only be displayed in the window you set.The set layer attribute parameter panel is as shown below:
Clever use of CSS MASK filter_Basic tutorial
 Figure 5 Layer attribute panel

Here I am The parent layer is "Layer4". I use the entire parent layer as the display window here, that is, it is visible when the child layer moves to the parent layer, and is not visible outside the parent layer.
3. We insert a circular image with a transparent background on the sub-layer. The main purpose of using a circular image here is that the projection of the searchlight is like a circle. In addition, the image part outside the circle must be transparent, otherwise the visible It will be a rectangular box moving. Then load a mask filter with the same color as the background color of the parent layer on the child layer, and enlarge the child layer so that it can completely cover the content of the parent layer, so that the content on the parent layer in the browser will only be circular. That part of the image is visible, which is exactly what we want.
4. Of course, if you want to produce the effect of a searchlight, you need to make the circular area move. This requires using the Timeline function of Dreamweaver. In DW3, first drag to the sub-layer so that the picture on it just covers the head of the parent layer content. Press "Ctrl F9" to bring up the timeline panel, drag the sub-layer to the timeline panel, and drag the last frame to 100 frames, then insert a key frame at the 50th frame, and overlap the sub-layer picture with the tail of the parent layer content, select "Loop" (loop play) and "Auto" (automatic play) on the timeline panel, everything OK.
A complex animation is completed. Press F12 to take a look. Isn’t it cool? !

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Making Your First Custom Svelte Transition Making Your First Custom Svelte Transition Mar 15, 2025 am 11:08 AM

The Svelte transition API provides a way to animate components when they enter or leave the document, including custom Svelte transitions.

Working With GraphQL Caching Working With GraphQL Caching Mar 19, 2025 am 09:36 AM

If you’ve recently started working with GraphQL, or reviewed its pros and cons, you’ve no doubt heard things like “GraphQL doesn’t support caching” or

Show, Don't Tell Show, Don't Tell Mar 16, 2025 am 11:49 AM

How much time do you spend designing the content presentation for your websites? When you write a new blog post or create a new page, are you thinking about

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

Creating Your Own Bragdoc With Eleventy Creating Your Own Bragdoc With Eleventy Mar 18, 2025 am 11:23 AM

No matter what stage you’re at as a developer, the tasks we complete—whether big or small—make a huge impact in our personal and professional growth.

Vue 3 Vue 3 Apr 02, 2025 pm 06:32 PM

It's out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

A bit on ci/cd A bit on ci/cd Apr 02, 2025 pm 06:21 PM

I'd say "website" fits better than "mobile app" but I like this framing from Max Lynch:

Let's use (X, X, X, X) for talking about specificity Let's use (X, X, X, X) for talking about specificity Mar 24, 2025 am 10:37 AM

I was just chatting with Eric Meyer the other day and I remembered an Eric Meyer story from my formative years. I wrote a blog post about CSS specificity, and

See all articles