Learn how to zoom/scale an element on hover with CSS.
Hover over the green box:
<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.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!