I am currently attempting to add a uniform glow effect around a hexagon created with CSS classes but due to the way the hexagon is drawn, the glow effect ends up with odd breaks that I cannot seem to fix.
.hexagon {
position: relative;
border-radius: 5px;
height: 125px;
width: 75px;
margin: 50px;
box-sizing: border-box;
border: 5px solid transparent;
border-top-color: black;
border-bottom-color: black;
display: inline-block;
}
.hexagon:before, .hexagon:after {
content: "";
border: inherit;
position: absolute;
top: -5px;
left: -5px;
background: inherit;
border-radius: inherit;
height: 100%;
width: 100%;
}
.hexagon:before {
transform: rotate(60deg);
}
.hexagon:after {
transform: rotate(-60deg);
}
.hexagon:hover, .hexagon:hover:before, .hexagon:hover:after {
box-shadow: 0 10px 2px -2px rgba(255,0,0,0.5), 0 -10px 2px -2px rgba(255,0,0,0.5);
}
<div class=hexagon></div>
You may add more padding inside the element and adjust the border radius. All line will cross and the radius will fix the shape :
.hexagon {
position: relative;
border-radius: 20px;
padding: 40px;
height: 125px;
width: 75px;
margin: 50px;
box-sizing: border-box;
border: 5px solid transparent;
border-top-color: black;
border-bottom-color: black;
display: inline-block;
}
.hexagon:before,
.hexagon:after {
content: "";
border: inherit;
position: absolute;
top: -5px;
left: -5px;
background: inherit;
border-radius: inherit;
height: 100%;
width: 100%;
}
.hexagon:before {
transform: rotate(60deg);
}
.hexagon:after {
transform: rotate(-60deg);
}
.hexagon:hover,
.hexagon:hover:before,
.hexagon:hover:after {
box-shadow: 0 10px 2px -2px rgba(255, 0, 0, 0.5), 0 -10px 2px -2px rgba(255, 0, 0, 0.5);
}
<div class=hexagon></div>
You can of course control the radius of your shape by changing simultaneously the padding and border-radius
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With