Open In App

How to zoom an element on Hover using CSS ?

In this article, we learn about how to zoom on hover using CSS. It is called pseudo-selector and used to select all the elements when the user moves the mouse over the elements. When the user hovering on the element the scale function is called to increase the dimensions of the element. It can be used on all the elements. An element must be declared in the document to see the working of this selector in all the elements.

Example:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to zoom an element
        on Hover using CSS ?
    </title>
    <meta name="viewport" content=
        "width=device-width, initial-scale=1">
  
    <style>
        * {
            box-sizing: border-box;
        }
  
        .sudo {
  
            padding: 50px;
            background-color: red;
            transition: transform .2s;
            width: 160px;
            height: 160px;
            margin: 0 auto;
            border-radius: 29px;
        }
  
        .sudo:hover {
            -ms-transform: scale(4.6);
            /* IE 9 */
            -webkit-transform: scale(1.5);
            /* Safari 3-8 */
            transform: scale(1.5);
        }
    </style>
</head>
  
<body>
    <center>
        <h1>
            GeeksForGeek
        </h1>
  
        <h2>
            How TO – Zoom on Hover
            in inline CSS
        </h2>
  
        <div class="sudo">
            Hover on Me
        </div>
    </center>
</body>
  
</html>

Output:

Supported Browsers: The supported browsers are listed below:


Article Tags :