Dark CSS

Cool Button Hover Effect using Html and CSS

Facebook
Twitter
WhatsApp

Project Demo

HTML CODE

				
					<html lang="en">

<head>
  <title>Button Hover Effect</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <!--Main container of button-->
  <div class="container">
    <!-- Button content -->
    <span class="text">Hover Me</span>
  </div>
</body>

</html>
				
			

css CODE

				
					* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    display: grid;
    height: 100%;
    place-items: center;
    background: #e8e8e8;
}

.container {
    display: inline-block;
    position: relative;
    overflow: hidden;
    background: #000;
    color: #fff;
    padding: 1rem 2rem;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 100%;
}

.container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #fff;
    clip-path: polygon(100% 0, 100% 100%, 0% 100%, 100% 100%);
    transition: clip-path .3s ease;
}

/* Layer that moves up on hover*/

.container:hover:before {
    clip-path: polygon(100% 0, 0 0, 0% 100%, 100% 100%);
}

.text {
    position: relative;
    mix-blend-mode: difference;
    display: block;
}

/* Animation on hover text that moves up*/

.container:hover .text {
    animation: move-up .3s ease forwards;
}

@keyframes move-up {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(80%);
    }

    51% {
        transform: translateY(-80%);
    }

    100% {
        transform: translateY(0);
    }
}