CSS3 fillet, shadow, transparent

Source: Internet
Author: User

CSS implementation of the round angle, shadow, transparent methods, the traditional methods are more complex, with CSS3 convenient many, although now the browser to CSS3 support is not very good, but in the near future CSS3 will be popular.

1. Rounded Corners

There are two ways to implement a fillet CSS3.

The first is the background image, the traditional CSS each element can have only one background image, but CSS3 can allow one element to have more than one background image. This adds 4 1/4-circle background images to an element that can be rounded at 4 corners.

HTML code
  1. . box {
  2. /* First define the 4 images to use as the background map */
  3. Background-image:url (/img/top-left.gif),
  4. URL (/img/top-right.gif),
  5. URL (/img/bottom-left.gif),
  6. URL (/img/bottom-right.gif);
  7. /* Then define non-repeating display */
  8. Background-repeat:no-repeat,
  9. No-repeat,
  10. No-repeat,
  11. No-repeat;
  12. /* Last definition 4 images shown in 4 corners */
  13. Background-position:top left,
  14. Top Right,
  15. Bottom left,
  16. bottom right;
  17. }

The second method is concise, directly with the CSS implementation, do not need to use the picture.

HTML code
    1. . box {
    2. /* The radius of the fillet can be defined directly */
    3. Border-radius:1em;
    4. }

But the second method has not been well supported, and currently Firefox and Safari (the same core chrome can), need to use a prefix

HTML code
    1. . box {
    2. -moz-border-radius:1em;
    3. -webkit-border-radius:1em;
    4. Border-radius:1em;
    5. }

2. Shadows

CSS3 's Box-shadow attribute can be used to directly implement shadows

HTML code
    1. IMG {
    2. -webkit-box-shadow:3px 3px 6px #666;
    3. -moz-box-shadow:3px 3px 6px #666;
    4. box-shadow:3px 3px 6px #666;
    5. }

The 4 parameters of this property are: Vertical offset, horizontal offset, width of the projection (degree of blur), color

3. Transparent

CSS is originally support transparent, IE browser is opacity property, IE is filter:alpha. However, there is a drawback to this transparency, which is that it causes the content of the application element to inherit it, such as having a Div,

HTML code
    1. <div style="Opacity:0.8;filter:alpha (opacity=80); Font-weight:bold; " >>
    2. Content
    3. </div>

If the background of a div like above is transparent, but the content of two words is also transparent, then you can use RGBA.

HTML code
    1. . alert {
    2. RGBA (0,0,0,0.8);
    3. }

The first 3 properties of this property represent the color red, green, blue, and the fourth is transparency. Both red and green are 0 for black, so Rgba (0,0,0,0.8) is setting the transparency of black to 0.8.

CSS3 makes the original difficult to achieve the effect is very simple, I hope that the browser to CSS3 as soon as possible to achieve the perfect support.

CSS3 fillet, shadow, transparent

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.