glowing buttons
Notes
.container a::after {
position: absolute; /* โญ๏ธ ไฝฟ็จ็ตๅฐไฝ็ฝฎ */
inset: 0; /* โญ๏ธ ่ฆ่ๆดๅ <a> */
content: ''; /* โญ๏ธ ๆฒๆๅ
งๅฎน๏ผ่ๆฏ่ฒๆไธ่ฆโ๏ธ */
background: linear-gradient(45deg, rgb(130, 204, 253), rgb(2, 2, 128), #003, rgb(255, 100, 95));
transition: 0.5s; /* */
}
.container a:hover::after {
/* โญ๏ธ glow effect */
inset: -3px;
filter: blur(10px);
}
ไฝฟ็จ ::after ไพ่ฃฝ้ <a> ๅ ็ด ใ่ๅ ใ็ๆๆใ
ๅฉ็จ background: linear-gradient ่ฃฝไฝใๅฝฉ่ฒ็ๅนป็ใๆๆใ
ๅฉ็จ transition ็ข็จฑใๅ็ซใๆๆใ
ๅฉ็จ :hover ่ inset: -3px, filter: blur() ่ฃฝ้ ใๆบขๅ ใๆๆใ
Code
/* CSS reset */
:root {
box-sizing: border-box;
--color-main: #0e1538;
}
* {
padding: 0;
margin: 0;
box-sizing: inherit;
}
/* body */
body {
/* flex */
display: flex;
justify-content: center; /* โญ๏ธ ๆฐดๅนณ็ฝฎไธญ */
align-items: center; /* โญ๏ธ ๅ็ด็ฝฎไธญ */
min-height: 100vh; /* โญ๏ธ ๅผท่ฟซไฝฟ็จๅ
จ้จ้ซๅบฆ */
background-color: var(--color-main);
}
/* container */
.container {
/* flex */
display: flex;
justify-content: center; /* โญ๏ธ ๆฐดๅนณ็ฝฎไธญ */
align-items: center; /* โญ๏ธ ๅ็ด็ฝฎไธญ */
flex-direction: column;
}
/* button */
.container a {
width: 160px;
height: 60px;
position: relative;
/* border: 1px solid white; */
background-color: white;
margin: 20px;
}
/* ๆ้่ๅ
*/
.container a::before,
.container a::after {
position: absolute; /* โญ๏ธ ไฝฟ็จ็ตๅฐไฝ็ฝฎ */
inset: 0; /* โญ๏ธ ่ฆ่ๆดๅ <a> */
content: ''; /* โญ๏ธ ๆฒๆๅ
งๅฎน๏ผ่ๆฏ่ฒๆไธ่ฆโ๏ธ */
background: linear-gradient(45deg, rgb(130, 204, 253), rgb(2, 2, 128), #003, rgb(255, 100, 95));
transition: 0.5s; /* */
}
.container a:nth-child(2)::before,
.container a:nth-child(2):after {
background: linear-gradient(45deg, rgb(130, 204, 253), rgb(2, 2, 128), #003, rgb(122, 255, 95));
}
.container a:hover::before {
inset: -3px;
}
.container a:hover::after {
/* โญ๏ธ glow effect */
inset: -3px;
filter: blur(10px);
}
.container a span {
/* โญ๏ธ center text node */
display: flex;
justify-content: center;
align-items: center;
position: absolute;
inset: 1px;
z-index: 1;
background-color: var(--color-main);
color: white;
text-transform: uppercase;
/* โญ๏ธ ้ฑ่ใๆ้้ขๆฟไบฎ้ขใ็ชๅบ็ๅฐๆน */
overflow: hidden;
}
/* ๆ้้ขๆฟไบฎ้ข */
.container a span::before {
content: '';
/* โญ๏ธ ๅๅทฆ็ชๅบ 50% ็ๅฏฌๅบฆ */
position: absolute;
inset: 0 50% 0 -50%;
background-color: rgba(255, 255, 255, 0.05);
/* โญ๏ธ ่ฎ้ทๆนๅฝขๅๅทฆๅพๆ 25 ๅบฆ */
transform: skew(25deg);
}
<div class="container">
<a href="#"><span>button</span></a>
<a href="#"><span>button</span></a>
</div>
Last updated