CSS button with neon light animation effect

  • Last updated: Nov 3, 2023
  • Views: 229
  • Author: Admin
CSS button with neon light animation effect

Hello colleagues.

In today's example, we will create a beautiful button with a neon light animation effect using pure CSS without using any JavaScript code.

 

HTML Code:

<body>
<a href="#">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
    Button
</a>
</body>

 

CSS Code:

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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #112233;
}

a {
    position: relative;
    display: inline-block;
    padding: 30px 45px;
    color: #4CD4B0;
    text-transform: uppercase;
    letter-spacing: 5px;
    text-decoration: none;
    font-size: 25px;
    overflow: hidden;
    transition: 0.2s;
}

a:hover {
    color: #27AE60;
    background-color: #4CD4B0;
    box-shadow: 0 0 10px #4CD4B0, 0 0 40px #4CD4B0, 0 0 80px #4CD4B0;
    transition-delay: 1s;
}

a span{
    position: absolute;
    display: block;
}

a span:nth-child(1){
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4CD4B0);
}

a:hover span:nth-child(1){
    left: 100%;
    transition: 1s;
}

a span:nth-child(3){
    bottom: 0;
    right: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(270deg, transparent, #4CD4B0);
}

a:hover span:nth-child(3){
    right: 100%;
    transition: 1s;
    transition-delay: 0.5s;
}

a span:nth-child(2){
    top: -100%;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, transparent, #4CD4B0);
}

a:hover span:nth-child(2){
    top: 100%;
    transition: 1s;
    transition-delay: 0.25s;
}

a span:nth-child(4){
    bottom: -100%;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(360deg, transparent, #4CD4B0);
}

a:hover span:nth-child(4){
    bottom: 100%;
    transition: 1s;
    transition-delay: 0.75s;
}

 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

YII2 defaultRoute - How to change default controller in template

YII2 defaultRoute - How to change default controller in template

Pure HTML/CSS search bar

Pure HTML/CSS search bar

HTML/CSS - Expandable Searchbar Animation

HTML/CSS - Expandable Searchbar Animation