HTML Element Style How to - Add shadow to image








Question

We would like to know how to add shadow to image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.badge_image {<!--from   w w w. j a v  a 2s  .  com-->
  float: left;
  -webkit-box-shadow: 1px 1px 5px 0px #a2958a;
  -moz-box-shadow: 1px 1px 5px 0px #a2958a;
  box-shadow: 1px 1px 5px 0px #a2958a;
}

.img2 {
  display: block;
}

.div2 {
  line-height: 0px;
}
</style>
</head>
<body>
  <div class="badge_image">
    <img
      src="http://www.java2s.com/style/download.png"
      height="75" width="75" />
  </div>
  <div class="badge_image">
    <img class="img2"
      src="http://www.java2s.com/style/download.png"
      height="75" width="75" />
  </div>
  <div class="badge_image div2">
    <img
      src="http://www.java2s.com/style/download.png"
      height="75" width="75" />
  </div>
  <br clear="all" />
  <br clear="all" />
  <img
    src="http://www.java2s.com/style/download.png"
    height="75" width="75" class="badge_image" />
</body>
</html>

The code above is rendered as follows: