Amazing Neon Light Hover Effect On Buttons Using Only HTML & CSS


 

Example :)

Source Code :)

HTML:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" type="text/css" href="style.css">

    <title>Neon Light Button</title>
</head>
<body>
    <button class="btn">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        Hover Me
    </button>
</body>
</html>

CSS:

@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

:root {
    --primary-color: #2196f3;
    --secondary-color: #255784;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background: var(--secondary-color);
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn {
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--primary-color);
    text-transform: uppercase;
    text-decoration: none;
    position: relative;
    cursor: pointer;
    padding: 1rem 3rem;
    overflow: hidden;
    transition: .2s;
}

.btn:hover {
    background: var(--primary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 10px var(--primary-color), 0 0 40px var(--primary-color), 0 0 80px var(--primary-color);
    transition-delay: 1s;
}

.btn span {
    position: absolute;
    display: block;
}

.btn:hover span {
    transition: 1s;
}

.btn span:nth-child(1) {
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--primary-color));
}

.btn:hover span:nth-child(1) {
    left: 100%;
}

.btn span:nth-child(3) {
    bottom: 0;
    right: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(to left, transparent, var(--primary-color));
}

.btn:hover span:nth-child(3) {
    right: 100%;
    transition-delay: .5s;
}

.btn span:nth-child(2) {
    top: -100%;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--primary-color));
}

.btn:hover span:nth-child(2) {
    top: 100%;
    transition-delay: .25s;
}

.btn span:nth-child(4) {
    bottom: -100%;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(to top, transparent, var(--primary-color));
}

.btn:hover span:nth-child(4) {
    bottom: 100%;
    transition-delay: .75s;
}

Video:

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
Design by - Blogger Templates