CSS Glowing Border Animation

CSS Glowing Border Animation
Code Snippet:CSS Glow Border Animation
Author: LIYRO
Published: January 18, 2024
Last Updated: January 22, 2024
Downloads: 3,300
License: MIT
Edit Code online: View on CodePen
Read More

This CSS Glowing Border Animation code creates an animated glowing border effect on a specified HTML element. The core role of the animated-border-box-glow class is to add a glowing border animation. It works by using CSS properties like blur, gradients, and keyframes to create a visually appealing glow around the specified HTML element.

This code is helpful for enhancing the visual appeal of your web page or specific elements by adding an eye-catching animated border glow effect. You can apply this effect to buttons, call-to-action elements, or featured content.

How to Create CSS Glowing Border Animation

1. Begin by creating the HTML structure where you want to apply the glowing border animation. You can use this code on buttons, containers, or other HTML elements. Place your target element within a parent container, as shown in the following code:

<div class="center-box">
  <!-- START Box -->
  <div class="animated-border-box-glow"></div>
  <div class="animated-border-box">
    <!-- Inside the Box -->
  </div>
  <!-- END -->
</div>

2. Next, you need to add the CSS code to your website. The CSS styles provided in the code create the glowing border effect. The key parts to note are the .animated-border-box-glow class and the @keyframes rotate animation. These are responsible for the glowing border effect.

/*// Glow Border Animation //*/
.cd__main{
   background: #000 !important;
}
.animated-border-box, .animated-border-box-glow{
  max-height: 200px;
  max-width: 250px;
  height: 100%;
  width: 100%;
  position: absolute;
  overflow: hidden; 
  z-index: 0;
  /* Border Radius */
	border-radius: 10px;
}

.animated-border-box-glow{
  overflow: hidden;
  /* Glow Blur */
  filter: blur(20px);
}

.animated-border-box:before, .animated-border-box-glow:before {
  content: '';
  z-index: -2;
  text-align: center;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) rotate(0deg);
  position: absolute;
	width: 99999px;
	height: 99999px;
	background-repeat: no-repeat;
	background-position: 0 0;
  /*border color, change middle color*/
	background-image: conic-gradient(rgba(0,0,0,0), #1976ed, rgba(0,0,0,0) 25%);
  /* change speed here */
	animation: rotate 4s linear infinite;
}

.animated-border-box:after {
	content: '';
	position: absolute;
	z-index: -1;
  /* border width */
	left: 5px;
	top: 5px;
  /* double the px from the border width left */
	width: calc(100% - 10px);
	height: calc(100% - 10px);
  /*bg color*/
	background: #292a2e;
  /*box border radius*/
	border-radius: 7px;
}

@keyframes rotate {
	100% {
		transform: translate(-50%, -50%) rotate(1turn);
	}
}

/*// Border Animation END//*/



/*// Ignore This //*/
body {
  margin: 0px;
}

.center-box{
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #1D1E22;
}

You can customize the glowing border animation by adjusting properties in the CSS code. Modify filter, animation, and other CSS properties to achieve the desired glow effect, color, and animation speed.

Assign the .animated-border-box-glow class to the HTML element you want to animate. For example, if you want to apply the animation to a button, your HTML would look like this:

<button class="animated-border-box-glow">Click Me</button>

That’s all! hopefully, you have successfully created a glowing border animation. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X