Effect How to - Create CSS3 Pyramid with hover effect








Question

We would like to know how to create CSS3 Pyramid with hover effect.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.shape {<!--   w ww  .  ja v a  2 s  .c o m-->
  margin: auto;
}

#one {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 60px solid #EEE;
}

#one:hover {
  border-bottom: 60px solid #CFCFCF;
}

#two {
  border-bottom: 75px solid #DDD;
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  height: 0;
  width: 100px;
}

#two:hover {
  border-bottom: 75px solid #92DCF4;
}

#three {
  border-bottom: 100px solid #AAA;
  border-left: 80px solid transparent;
  border-right: 80px solid transparent;
  height: 0;
  width: 220px;
}

#three:hover {
  border-bottom: 100px solid #51D988;
}
</style>
</head>
<body>
<body>
  <div class="shape" id="one"></div>
  <div class="shape" id="two"></div>
  <div class="shape" id="three"></div>
</body>
</body>
</html>

The code above is rendered as follows: