Open In App

Bottom Half Hidden Text Revealer on Mouse Over in CSS

In this CSS effect, the bottom half of the text is hidden, and when the user hovers over the text, some portion of the text becomes visible. This effect can be created by giving 0 brightness to text to be hidden and using the clip-path property to make it visible. JavaScript is used to get the cursor position.

Approach:



Example: In this example, we are implementing the above-explained approach.




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible"
                content="IE=edge">
 
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
 
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
            overflow: hidden;
            background-color: black;
        }
         
        .upper_text,
        .pointer {
            position: fixed;
            top: 40vh;
            left: 40vw;
            width: 350px;
            color: chartreuse;
            font-size: 50px;
            cursor: all-scroll;
        }
         
        .upper_text {
            clip-path: polygon(0% 0%,
                100% 0%, 100% 50%, 0% 50%);
        }
    </style>
</head>
 
<body>
    <div class="upper_text">
        Geeks For Geeks
    </div>
 
    <div class="pointer">
        Geeks For Geeks
    </div>
    <script>
        document.addEventListener('mousemove', (e) => {
            const pointer = document.querySelector('.pointer');
             
            pointer.style.clipPath =
            `circle(30px at ${e.offsetX}px ${e.offsetY}px)`;
        });
    </script>
</body>
</html>

Output:




Article Tags :