How to enrich the image style (Corner shadow gradient) using the css3 attribute _ html5 tutorial tips-

Source: Internet
Author: User
Using the image as a background-image, the style browser can be well rendered. I will introduce how to use box-shadow, border-radius and transition to create different image styles (Corner shadow gradient) in css3, box-shadow and border-radius are directly used on the image. The browser cannot render the image properly. However, if the image is used as the background-image, the added style browser can render the image well. I will introduce how to use box-shadow, border-radius, and transition to create different image styles.
Problem
By viewing the demo, we can see that we have set border-radius and Embedded box-shadow for the first line of images. Firefox renders the border-radius of the image, but does not render the Embedded box-shadow. Neither chrome nor Safari is rendered.

The Code is as follows:


. Normal img {
Border: solid 5px #000;
-Webkit-border-radius: 20px;
-Moz-border-radius: 20px;
Border-radius: 20px;
-Webkit-box-shadow: inset 0 1px 5px rgba (0, 0,. 5 );
-Moz-box-shadow: inset 0 1px 5px rgba (0, 0,. 5 );
Box-shadow: inset 0 1px 5px rgba (0, 0,. 5 );
}


Firefox Effect:

Chrome/safari


Work und
To enable border-radius and Embedded box-shadow to work normally, we need to convert the image into a background-image method.

Dynamic Mode
To do this dynamically, we need to use jquery to add a background image packaging for each image. The following js Code adds a span package for each image. The background image path of the span is the image path.
The code is relatively simple and I don't think it is necessary to explain it. You can directly query the jquery api.

The Code is as follows:


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.