CSS кнопка з ефектом анімації неонового світла
- Останнє оновлення: 3 Листопада 2023 р.
- Перегляди: 58
- Автор: Адмін

Колеги всім привіт.
У цьому прикладі ми створимо на чистому CSS без використання JavaScript коду красиву кнопку з ефектом анімації неонового світла.
HTML Код:
<body>
<a href="#">
<span></span>
<span></span>
<span></span>
<span></span>
Button
</a>
</body>
CSS Код:
* {
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;
}
Дякую всім, я сподіваюся що вам моя стаття хоч чимось допомогла.