How TO - Zoom on Hover


Learn how to zoom/scale an element on hover with CSS.


Zoom on Hover

Hover over the green box:


How To Zoom on Hover

Example

<style>
.zoom {
  padding: 50px;
  background-color: green;
  transition: transform .2s; /* Animation */
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.zoom:hover {
  transform: scale(1.5); /* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */
}
</style>

<div class="zoom"></div>
Try it Yourself »

Tip: Go to our CSS Transform Tutorial to learn more about how to scale elements.


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.