A detailed description of the layer shadow and text shadow effects using CSS3

Source: Internet
Author: User
Tags transparent color
Box-shadow layer Shadows

Box-shadow: Shadow type x horizontal offset (preferably positive or negative) Y vertical offset (preferably positive or negative) shadow size shadow Extended Shadow color value
The shadow type can be omitted, and the default is an outer projection, which is an inner shadow effect when its value is inset.
The x horizontal offset and y vertical offset are positive negative values, and when x is negative, it is projected on the left, and the projection is on the right. When Y is negative, it is projected on the top, and is projected below.
The size and extension of the shadow is the same as the principle inside PS.

Browser compatibility:
Different browser compatibility, Mozilla Kernel browser is written as follows (but the new version of Firefox has no need to add):
-moz-box-shadow: Shadow type x horizontal offset (preferably positive or negative) Y vertical offset (preferably positive or negative) shadow size shadow Extended Shadow color value
The browser of the WebKit kernel is written as follows:
-webkit-box-shadow: Shadow type x horizontal offset (preferably positive or negative) Y vertical offset (preferably positive or negative) shadow size shadow Extended Shadow color value

Example one:

<p class= "Shadow" ></p>   . shadow{    width:200px;    height:50px;    box-shadow:3px 3px 3px 3px #000;    /*-moz-box-shadow:3px 3px 3px 3px #000;    Mozilla Kernel Browser, which is represented by Firefox, has already supported this property in Firefox's current version, so it is not necessary to add-moz*/-webkit-box-shadow:3px 3px 3px 3px #000;   }


Change the Box-shadow projection type to inset:

Example two:

<p class= "Shadow" ></p>   . shadow{    width:200px;    height:50px;    box-shadow:0 -5px 5px 0 red,5px 0 5px 0 yellow,0 5px 5px 0 green,-5px 0 5px 0 blue;    /*-moz-box-shadow:0 -5px 5px 0 red,5px 0 5px 0 yellow,0 5px 5px 0 green,-5px 0 5px 0 blue;    The Mozilla Kernel browser, which is represented by Firefox, has already supported this property in Firefox's current version, so no more-moz*/-webkit-box-shadow:0 -5px 5px 0 red,5px 0 5px 0 yellow,0 5px 5px 0 gree n,-5px 0 5px 0 blue;   }


Text-shadow Text Shadow

Above we discussed about CSS3 layer Shadow Box-shadow to achieve the effect of layer shadow, today we learn how to achieve the effect of text shadow, will be used to css3 another property Text-shadow, these two effects enhance the texture of the layer and text, respectively, Create a stereoscopic effect.

Grammar:

Text-shadow:none | <length> None | [<shadow>,] * <shadow> or none | <color> [, <color>]*

Displacement on the text-shadow:x axis (positive or negative), displacement on y-axis (plus or minus), width of shadow, color value of shadow

Description
Like a layer shadow, it can also apply one or more sets of shadow effects to the same object, separated by commas. The x-axis offset can be positive or negative, offset to the right when X is positive, and left offset when negative. The y-axis offset can be positive or negative, offset downward when x is positive, and offset upward when negative. The color value of the shadow can be #xxx, RGB, or rgba transparent color.

Example: Text-shadow

The display results are as follows:

Compare Box-shadow

The effect is as follows:

The display results are as follows:

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.