Can I use CSS to add shadows to images?

Source: Internet
Author: User

Inserting images on a webpage is not uncommon. However, for the sake of appearance, we need to add shadows to images. When there are a large number of images, the workload is very large. Repetitive work and ineffective. Is there a way to use CSS to add shadows to images?
There is a concept in CSS that everyone should be familiar with, that is, relative positioning position: relative ;. We should learn to use the attributes provided by CSS flexibly. To add a shadow to an image, we can use position: relative; to implement relative positioning. For details about the position attribute, refer to here.
Let's look at the following css code:

The code is as follows: Copy code
. Waiwei {
Position: relative;
Background: # eee;
Margin: 0 auto;
Width: 200px;

. Tupian {
Background: # fff;
Border: 1px solid # c00;
Padding: 0;
Position: relative;
Top:-5px;
Left:-5px;
}
. Tupian img {
Vertical-align: bottom;/* Remove the gap below the image */
}

We insert an image into XHTML. The following is the XHTML code:

The code is as follows: Copy code
<Div class = "waiwei">
<Div class = "tupian">

</Div>
</Div>

We should be able to understand the CSS and XHTML in this issue, and the principle is also very clear. It is to use relative positioning to stagger the image positioning and the container and fill in the table with colors, and finally form a shadow effect.
So far, this effect has been successfully completed. What? Not beautiful enough? Should it be more refined? These work will be done by the person who pursues perfection.

 

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.