Examples of CSS Filter (3) Blur attributes

Source: Internet
Author: User

If you use your hands to quickly draw a dry oil painting, the screen will become blurred. The blur attribute under CSS can achieve this fuzzy effect.
Let's take a look at the expression of the blur attribute:
Filter: blur (add = add, direction, strength = strength)
We can see that the blur attribute has three parameters: add, direction, and strength.
The Add parameter has two values: true and false. Indicates whether the image is blurred.
The Direction parameter is used to set the fuzzy Direction. The blur effect is performed clockwise. The value 0 indicates the vertical upward direction. Each 45 degrees is a unit. The default value is 270 degrees to the left. The corresponding relationship between the angle and direction is shown in the following table:
 
Let's look at an example.

The code is as follows: Copy code

<Html>


Does it look like a kaleidoscope? In this example, some JavaScript statements are added. The code is as follows:

The code is as follows: Copy code
<Html>
<Head>
<Title> blur css </title>
<Script>
Function handlechange (obj)
// * Set a loop function handlechange with the Object obj *//
{With (obj. filters (0) // * filter attribute of Obj *//
{If (strength <255) // * sets the cyclic condition *//
{Strength + = 1; direction + = 45 ;}
// * Add 1 to strength every cycle, and add 45 degrees to direction *//
}
}
</Script>
</Head>
<Body>
<P> Style = "filter: blur (strength = 1 )"
Onfilterchange = "handlechange (this)">
// * Import an image. The initial blur attribute strength is equal to 1 and the onfilterchange function is called.
Count *//
</P>
</Body>
</Html>

Note: In javascript, the blur attribute is defined as follows:
[OBlurfilter =] object. Filters. blur

This is a complex example of the Blur attribute. In the next section, I will introduce two simple blur attribute effects.

You can also set fonts on the page through the blur attribute. If the value of the add parameter in the blur attribute of the font is defined as 1, the font effect is as follows (as shown in the figure below ):

 

The code is as follows: Copy code

The implementation code of this effect is as follows:

<Html>
<Head>
<Title> filter blur </title>
<Style> // * CSS style definition start *//
<! --
Div {width: 200;
Filter: blur (add = true, direction = 90, strength = 25 );}
// * Set the DIV style and filter the blur attribute *//
-->
</Style>
</Head>
<Body>
<Div style = "width: 702; height: 288">
<P style = "font-family: lucida handwirting italic;
Font-size: 72; font-style: bold; color: rgb (145,); ">
LEAF </p>
// * Define the font name, size, style, and foreground color *//
</Div>
</Body>
</Html>

We can see that strength is set to 25. If you increase the value, it will be very exaggerated. At the same time, the value of the Direction parameter is 180, which is displayed

Setting the font with the blur attribute can achieve a lot of results. You can modify the direction and strength to achieve a variety of effects. You can try it by yourself.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.