CSS shimmer effect does not smoothly transition between borders

Currently, I'm diving into a tutorial on YouTube that teaches how to craft a CSS Glowing Border Animation

After putting in the effort to replicate the animation, I noticed a glitch that's been bothering me. It seems like there's an abrupt separation between two images during the transition, giving off a disjointed appearance.

Can anyone guide me on smoothing out this transition hiccup?

I've set up a JSFiddle to better illustrate my issue:

* {
  margin: 0;
  padding: 0;
}

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

.box {
  position: relative;
  width: 300px;
  height: 300px;
  color: #fff;
  font: 300 2rem 'Montserrat';
  text-align: center;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}

.box::before,
.box::after {
  content: '';
  z-index: -1;
  position: absolute;
  width: calc(100% + 30px);
  height: calc(100% + 30px);
  top: -15px;
  left: -15px;
  background: linear-gradient(45deg, #0096FF, #0047AB, #000000, #6082B6, #87CEEB, #00008B, #145DA0, #00008B, #145DA0, #0096FF, #0047AB, #000000, #6082B6, #87CEEB);
  background-repeat: repeat;
  border-radius: 5px;
  background-size: 600%;
  animation: border 12s linear infinite;
}

.box::after {
  filter: blur(25px);
}

@keyframes border {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 250% 250%;
  }
}
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>

<div class="box">
  Greetings fellow developer!
</div>

Additional note: The animation appears seamless initially, but around the 7-second mark, the "cut off" effect occurs, disrupting the smooth transition flow.

Answer №1

To create the desired effect, your gradient should have a repetitive pattern. Set the size to 200% 200%, then use a repeating gradient where the first color starts at 0% and the last one at 50%. The list of colors should be repeated twice but in reverse order.

body {
  background: #151320;
}

.box {
  position: relative;
  width: 300px;
  height: 300px;
}

.box::before,
.box::after {
  content: '';
  z-index: -1;
  position: absolute;
  inset: -15px;
  background: 
   repeating-linear-gradient(45deg,
    #0096FF 0%, #0047AB, #6082B6, #87CEEB, #00008B,
    #00008B, #87CEEB, #6082B6,#0047AB,#0096FF 50%);
  border-radius: 5px;
  background-size: 200% 200%;
  animation: border 2s linear infinite;
}

.box::after {
  filter: blur(25px);
}

@keyframes border {
  0% {
    background-position: bottom left;
  }
  100% {
    background-position: top right;
  }
}
<div class="box">
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to prioritize CSS selectors in a specific sequence?

I possess a pair of div elements: div class="one two three" div class="three two one" Is it probable to formulate a CSS regulation that exclusively focuses on ".one.two.three" and does not encompass ".three.two.one" ? ...

Implementing an interactive tab feature using jQuery UI

Recently, I was working on a project involving HTML and jQuery. Now, my goal is to create a dynamic tab with specific data when a button is clicked. This is my code for the JQuery-UI tab: $(document).ready(function() { var $tabs = $("#container-1 ...

Moving a DOM element within AngularJS to a new location

I have created an angular directive that functions like a carousel. To keep the dom element count low, I delete elements from the dom and then re-insert them using angular.element to select, remove, and insert items as shown below: app.directive('myD ...

AngularJS has the ability to handle the value of one input based on the value of another input

How can I ensure that if one input has a value, the other must also be filled in AngularJS? I'm looking for the best approach to handle this requirement in an angular way. Any suggestions? Below is my code: <div class="form-group recipe_item" ng ...

Curious as to why JavaScript restricts the use of two variables entering at the same time

Currently, I am tackling an Ajax-php livesearch programming challenge. I am facing an issue where JavaScript is unable to receive the values of 2 parameters that I want to input in HTML input boxes. Any idea why this might be happening? This is my HTML co ...

What is the process for dynamically populating a select dropdown based on the selection made in another select dropdown?

I need to dynamically populate the second select box based on the option selected in the first select box. Here's what I have tried so far, but it doesn't seem to be working as expected. HTML: <form id="step1"> <p> Creat ...

At what point will the browser display changes made to css using jQuery?

When I run my JavaScript code in Firebug, it looks like this: tr=$(this).parent('tr'); tr.find('.img-delete').css('display','block'); However, I am unable to see the change reflected on the browser. Is there a wa ...

Bootstrap - placement of label to the left of the checkbox

Here is an example of a checkbox I am working with: <div class="form-check"> <input class="form-check-input" type="checkbox" value="" id="defaultCheck1"> <label class="form-check-label" for="defaultCheck1"> Default checkbox < ...

Text vanishing upon the loading of an HTML webpage

I am experiencing an issue where the text on my webpage disappears after it loads, and I am struggling to figure out the cause. (I did not create the site) The white text displayed on top of the header image initially appears correctly but then vanishes. ...

What is the best way to display long text in a browser alert without it being cut off?

Seeking to display a large amount of data in an alert box, but only a portion is currently visible. The following text is all that can be seen: ["19467,1496257152583","19227,1496256651094","19469,1496257033968","17285, ...

Adjust Fabric js Canvas Size to Fill Entire Screen

Currently, I am working with version 4.3.1 of the Fabric js library and my goal is to adjust the canvas area to fit its parent div #contCanvasLogo. I have tried multiple approaches without success as the canvas continues to resize on its own. Below is the ...

"Enhance your listening experience with an audio player featuring album covers as captivating

Is there a way to create an audio player with the album cover image serving as the background, while ensuring all control buttons are displayed on top of that same image? I attempted using the following code snippet: <audio controls = 'controls&ap ...

Button click triggering XMLHttpRequest not functioning properly due to null

I am facing an issue with my webpage. When I click on a certain section labeled as "trigger," it is supposed to print the content in the "#content" page. However, I want it to redirect back to the "home" section when I click on the "BACK" button that appea ...

I could use some help navigating payment gateways

I'm new to payment gateways and would appreciate any recommendations or advice. ...

Internet Explorer will automatically apply a blue border to a div element when a CSS gradient is utilized

I'm attempting to create a gradual fading gray line by using a div that is sized at 1x100px with a CSS gradient applied for the fade effect. The only issue I am encountering is in Internet Explorer where the div is displaying a blue border which I am ...

Ways to merge two select options in a form

I'm attempting to merge the selections from two dropdown menus in a form into one variable before submitting the form. Here is an overview of my code: In new.html.erb (for RoR): <%= form_for :character, url: characters_path, method: :post do |f| ...

Tips for using Python to capture specific HTML snippets

Here is a Python code snippet that I am working on: def parseAddressInfo(text): text = re.sub('\t', '', text) text = re.sub('\n', '', text) blocks = re.findall('<div class="result-box" ...

Utilizing numerous 'select' HTML elements with Vue.js and Materializecss

I've been working on creating an HTML multiple select form element with Vue.js and encountered an interesting issue. Everything was functioning perfectly following the guidance provided in this resource. However, when I decided to incorporate the Mate ...

Error in NodeJS (EJS): Unable to locate stylesheet file

Having trouble adding a CSS file to my Node.js project with the EJS Template Engine. The file cannot be found when trying to access it. GET http://localhost/css/bulma.css net::ERR_ABORTED 404 (Not Found) Project folder structure ./index.js ./views ...

html search table td

How can I perform a search in a specific column of a table? Here is the JavaScript script and input tag that I am using: <script type="text/javascript"> function searchColumn() { var searchText = document.getElementById('searchTerm ...