HTML Element Style How to - Zoom image and div








Question

We would like to know how to zoom image and div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.box {<!--   w ww. j ava 2s . co m-->
  position: relative;
  margin: 20px;
  width: 20em;
  height: 20em;
  border: 1px solid rgb(77, 77, 77);
  box-shadow: 0px 0px 4px 0px rgb(189, 189, 189), 0px 0px 0px 0px black inset;
  -webkit-transition: all 1s;
}

.box:hover {
  height: 40em;
  width: 40em;
}

.box:before {
  content: '';
  position: relative;
  left: 0;
  width: 40%;
  height: 40%;
  top: 30%;
  background:url('http://www.java2s.com/style/download.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: inline-block;
}
</style>
</head>
<body>
  <div class="box"></div>
</body>
</html>

The code above is rendered as follows: