The CSS3 animations are lightning quick and the background image appears slightly unsteady

Is there a way to slow down the background change and stop it from shaking too fast? If so, please help me with this.

HTML

<!-- Banner -->
<section id="banner">
    <div class="inner">
        <h2>Enhancing Your <br />Ways</h2>
        <p>A free platform for scheduling</p>
    </div>
</section>

CSS (Animation Delays not working)

<!--The animation-delays not working--> 
@keyframes changebackground {
  0% {
    background-image: url("../Images/4.jpg");
    animation-delay:5s;
  }
  25% {
    background-image: url("../Images/1.jpg") ;
    animation-delay:5s;
  }
  50% {
    background-image: url("../Images/2.jpg") ;
    animation-delay:5s;
  }
  100% {
    background-image: url("../Images/3.jpg");
    animation-delay:5s;
  }
}

#banner {
  margin-top:2.9em;
  background-image: url("../Images/4.jpg");
  background-position:center;
  background-repeat:no-repeat;
  padding:22em 0em 8em 0em;
  background-size:cover;
  width:100%;
  float:left;
  animation-name:changebackground;
  animation-iteration-count:infinite;
  animation-duration:2s;   
  animation-delay:5s;
}

Answer №1

To adjust the speed of the animation, focus on changing the duration property rather than the delay property. Increase the value of animation-duration for a slower animation effect. For example, setting it to 20s will result in each image transition taking around 5s. If you want a longer pause between switches, like 25s, then set the duration as 100s. Note that animation-delay only adds a delay before the animation starts and does not impact its overall speed.

If you are experiencing shaking effects, I recommend sharing a demo of your code so I can provide tailored solutions. Consider preloading all background images to prevent any potential issues.

@keyframes changebackground {
  0% {
    background-image: url("http://lorempixel.com/200/200/nature/4");
  }
  25% {
    background-image: url("http://lorempixel.com/200/200/nature/1");
  }
  50% {
    background-image: url("http://lorempixel.com/200/200/nature/2");
  }
  75% {
    background-image: url("http://lorempixel.com/200/200/nature/3");
  }
}
#banner {
  margin-top: 2.9em;
  background-image: url("http://lorempixel.com/200/200/nature/4");
  background-position: center;
  background-repeat: no-repeat;
  padding: 22em 0em 8em 0em;
  background-size: cover;
  width: 100%;
  float: left;
  animation-name: changebackground;
  animation-iteration-count: infinite;
  animation-duration: 20s; /* set this */
  animation-delay: 5s;
}
<section id="banner">
  <div class="inner">
    <h2>Enhancing Your <br />Ways</h2>
    <p>A free platform for schedualing</p>
  </div>
</section>

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

Disable automatic focus on first button in PrimeNG Dialog

I am looking for a way to stop the autofocus on the first input element when opening the PrimeNG dialog. <p-dialog header="User Details" [(visible)]="displayDialog" [responsive]="true" showEffect="fade" [modal]="true" (onAfterHide)="onDialogHide ...

Choose only ul elements up to a specific level of depth

ul, ul ul, ul ul ul { list-style: none; margin: 0; padding: 0; } Inquiry: Is there a specific selector that I can utilize to apply styles to every nth level of ul? For instance: ul > ul ...

Staggered Drop-Down Menus

I've created a custom CSS drop-down menu that works well, but I've realized that updating this menu across all the HTML pages on my website would be a tedious task. If I ever need to add a new section and tier to the menu, I'd have to update ...

Update the Django translation file with new modifications

Currently, I am in the process of developing a web application using Django and have recently integrated Django allauth to streamline the creation of my user interface. I have successfully customized the templates by incorporating the templates from their ...

Trouble with Unveiling the Secondary Accordion

I am having issues adding a second accordion next to the existing one. Even though the code is working fine in the tryit editor v3.6 online, it doesn't seem to display correctly for me. I have made sure that I am using the latest versions of all scrip ...

Transitioning between different hues using specific fraction values

On my website, there is a variable called 'x' which represents a percentage. I am looking for a way to assign colors based on this percentage - with 0% being red and 100% being blue. For example, if 'x' is 50%, the color should be a mix ...

Ensure the footer is positioned at the bottom of the page using Bootstrap

I am having trouble with placing my footer at the end of the page when there is only a little text. I added h-100 to the container to try and fix it. <div class="container h-100" style="margin:40px;"> <!-- wrapper for all containers --> Howev ...

Customize HTML styles using Angular Material

I've noticed that my index.html file has a lot of style elements when using Angular Material, and I'm not sure why. Here's an example in the header element where different classes are used for Angular Material components. https://i.sstatic. ...

Tips for inserting a rotated image using CSS

I've created the following code snippet. However, there is a new requirement stating that the image needs to be rotated by 180 degrees. How can I make this happen? #cell { background-image: url("../images/logo.PNG"); background-attachment: fixed; b ...

Enable the use of custom tags containing hyphens in the kses filter for WordPress

I developed a specialized Wordpress plugin that enables users to incorporate custom HTML element tags (such as <my-element>) into the content of a Post. This allows users without the unfiltered_html capability to utilize predefined custom tags. The ...

Always ensure that the horizontal scrollbar is visible without the need for vertical scrolling

I'm attempting to create a data grid-style layout where the left side is fixed and only the right side is scrollable. However, the entire div needs to be vertically scrollable. The concept is functioning correctly, but the horizontal scrollbar appears ...

Executing Jquery code inside a PHP function

I am facing an issue with a form on my website where the form entries are not clearing when the submission message is displayed. I believe using Jquery to hide the form entries upon submission would solve this problem. The form in question has the ID of ...

Tips on reducing the height and improving responsiveness in Bootstrap 4

I've been struggling to adjust the image height to take up 75% of the screen. I attempted using height: 75%; and class="h-75", but it doesn't seem to be effective. Currently, I have class="h-800" with h-800 { height: 800px; }, ...

Tips on creating Twitter Bootstrap tooltips with multiple lines:

I have been using the function below to generate text for Bootstrap's tooltip plugin. Why is it that multiline tooltips only work with <br> and not \n? I would prefer to avoid having any HTML in my links' title attributes. Current Sol ...

Update the CAPTCHA, while also refreshing the entire registration form

JavaScript Snippet <script language="javascript" type="text/javascript"> function updateCaptcha() { $("#captchaimage").attr('src','new_captcha_image.php'); } </script> New Image Code <img src="new_ ...

Stylish Fonts with Bootstrap 4 and Font Awesome

I've encountered a little issue. I'm attempting to horizontally center each icon within a div, but my attempts so far have been unsuccessful. <div class="row"> <div class="bg-inverse p-x-1 col-xs-12 default-1 "> <div clas ...

What could be causing this issue with my JavaScript code?

Here is the code I have: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <script type="module"> import * a ...

Merging backend code (Java and Python) into HTML for seamless integration

While I have a solid background in back-end coding languages like Java and Python, the task at hand requires integrating this code into a website. The backend code comprises various methods and classes to encrypt text messages using encryption techniques ...

Issue with data type not refreshing in mySQL Workbench

I'm facing an issue with changing the datatype of my "first_name" column. I want it to be VARCHAR(45), but it's stuck at INT(11) as shown in the table diagram and connection provided below. https://i.sstatic.net/0CbkD.png https://i.sstatic.net/8 ...

Place a central div above and nestled between two other divs using Foundation Zurb

Recently, I've started using Foundation and I must say, I'm quite impressed with it. However, I have a query regarding centering the logo in between two full divs horizontally. The current code I have works well but doesn't adapt to screen c ...