Spare Material:
1.png
Shadow.png
The first way: the use of negative margins to achieve
Eventually:
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <Metaname= "Viewport"content= "Width=device-width, initial-scale=1, maximum-scale=1, User-scalable=no"> <title>Using Backgrounds to achieve shadows</title></Head><Body> <Divclass= "Image_warpper"> <imgsrc= "1.jpg"width:200px; height:200px;/> </Div></Body></HTML>
Image_warpper { float : left ; background : url (" shadow.png ") no-repeat bot Tom right ; } { Background: #fff ; padding : 4px ; margin : -4px 4px 4px-4px ; Vertical-align : bottom ; border : 1px solid #eee ; }
The second way, instead of using a negative margin, is to use the Position:relative property
. Image_warpper{float: Left;background:URL ("shadow.png") No-repeat bottom Right; }. Image_warpper img{background:#fff;padding:4px;position:relative;vertical-align:Bottom;Border:1px solid #ccc;Top:-4px; Left:-4px; }
The effect is as follows:
The Third Way: Css3-box-shadow
Incidentally review its syntax:
Image_warpper { float : left ; background : url (" shadow.png ") no-repeat bot Tom right ; } { Background-colo R : #fff ; padding : 4px ; Vertical-align : bottom ; border : 1px solid #ccc ; Box-shadow : 4px 4px #ccc ; }
This property is currently supported by modern browsers: Ie9+, Firefox 4, Chrome, Opera, and Safari 5.1.1 support Box-shadow properties.
CSS Projection Implementation method