css2.1实现图片添加阴影效果
2016-12-15 17:08
337 查看
盒子里面放了img标签,盒子浮动后,盒子的背景图片(就是阴影图片)会应用图片的宽高。
为了显示效果明显,我给背景图案加了边框,只要图片大小不超过背景图片都能实现阴影边框,演示地址:http://down.yesyes.wang/book/04/shadow.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> /* 核心技术就是float:left ,clear:right, 盒子脱离文挡流后,背景图片会应用盒子的高度*/ .shadow{ border: 1px solid red; background: url('img/shadow.gif') no-repeat bottom right; /* margin: 5px; */ float: left; clear: right; } .shadow img{ display: block; width: 300px; height: 300px; /* 向左上角偏移5px */ /* margin: -5px 5px 5px -5px; */ /* 或者使用相对定位 */ position: relative; top: -5px; left: -5px; /* border: 1px solid red; padding: 4px; */ } </style> </head> <body> <div class="shadow"> <img src="img/dunstan.jpg"> </div> </body> </html>
为了显示效果明显,我给背景图案加了边框,只要图片大小不超过背景图片都能实现阴影边框,演示地址:http://down.yesyes.wang/book/04/shadow.html
相关文章推荐
- 纯CSS实现的当鼠标移上图片添加阴影效果代码
- 纯CSS实现鼠标移上图片添加阴影效果
- Android实现图片添加阴影效果的2种方法
- css样式实现给图片添加阴影效果
- 图片阴影效果的实现
- CSS实现图片像框阴影效果
- HTML5实现的图片无限加载的瀑布流效果另带边框圆角阴影
- CSS实现图片阴影效果
- Android 图片合成:添加蒙板效果 不规则相框 透明度渐变效果的实现
- 图片阴影效果的实现
- CSS完美实现图片阴影效果
- css实现跨浏览器的盒阴影效果告别图片实现类似效果
- 用相对定位实现简单的图片边框阴影效果
- Android 图片合成:添加蒙板效果 不规则相框 透明度渐变效果的实现
- Android 图片合成:添加蒙板效果 不规则相框 透明度渐变效果的实现
- Android实现图片阴影效果
- 为图片添加阴影效果---css3(box-shadow)
- 为图片添加阴影效果
- 实现图片翻转效果--动态选择添加图片
- Android 图片合成:添加蒙板效果 不规则相框 透明度渐变效果的实现