Page Widget How to - Create pure css expandable








Question

We would like to know how to create pure css expandable.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.expandable .hidden {<!--  ww  w  .  j  a v  a 2  s  .c o  m-->
  display: none;
}

.expandable:active .hidden, .expandable .hidden:hover {
  display: block;
}

.min {
  width: 50px;
  height: 50px;
  background: green;
  cursor: -moz-zoom-in;
  cursor: -webkit-zoom-in;
}

.full {
  width: 200px;
  height: 200px;
  background: yellow;
  position: relative;
  top: -50px;
}
</style>
</head>
<body>
  <div class="expandable">
    <div class="min"></div>
    <div class="hidden full"></div>
  </div>
</body>
</html>

The code above is rendered as follows: