The images have not been fading as intended

My HTML code is supposed to display one image fading into another, but the issue I'm facing is that the new image appears before the previous one has completely faded out. Can someone please help me identify what's wrong with my code?

<!doctype html>
<html>
 <head>
  <title>Interactive Alphabet Learning</title>

  <style>

   #crossfade > img { 
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    color: transparent;
    opacity: 0;
    z-index: 0;
    -webkit-backface-visibility: hidden;
    -webkit-animation: imageAnimation 156s linear infinite 0s;
    -moz-animation: imageAnimation 156s linear infinite 0s;
    -o-animation: imageAnimation 156s linear infinite 0s;
    -ms-animation: imageAnimation 156s linear infinite 0s;
    animation: imageAnimation 156s linear infinite 0s; 
   }

   ... (omitted for brevity)

  </style>
 </head>

 <body style="background-color:yellow">
  <h1 style="color:black; text-align:center; font-family:Comic Sans MS">Interactive Alphabet Learning</h1>
  <hr style="border-color:#E30B5D">

  <div id="crossfade">
     ... (omitted for brevity)
  </div>

 </body>
</html>

Answer №1

Based on the context of your inquiry, it seems you are looking to have the current image completely fade out before the next image starts fading in.

The issue with the CSS lies in the keyframes being set up for the fading process from 0% to 25% of the total animation duration, which is specified as 156 seconds at the beginning. This results in the animation taking place over 39 seconds (25% of 156s) instead of the intended 6 seconds.

If you intend to cycle through 26 images, consider adjusting the percentages as follows:

@keyframes imageAnimation { 
    0% { opacity: 0;
         animation-timing-function: ease-in; }
    1.282% { opacity: 1;
         animation-timing-function: ease-out; }
    2.564% { opacity: 1 }
    3.846% { opacity: 0 }
    100% { opacity: 0 }
}

These values are determined by the calculation 6/156 = 3.846%.

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

PHP Algorithm - Duplicating items retrieved from MySQL query within a While Loop for each iteration

I'm struggling to understand the situation at hand. I have 3 tables - tag, post, and tag_post - all mapped out properly. On a page where posts are displayed, I first execute a query SELECT * from POST. Within the loop for these results, I then run an ...

Boosting Your Theme - Eliminating Redundant Styles

Currently, I am facing more of a best practice issue rather than a coding one. I am in the process of creating a custom bootstrap theme inspired by https://github.com/HackerThemes/theme-kit. Although I have a functional theme that I am satisfied with, I am ...

The LESS file could not be located. Attempted to find -

My directory structure is as follows: C:. └───static ├───custom_stuff │ presets.css │ presets.less │ └───index index.less However, I'm encountering an issue where index.less c ...

Python: Remove tag and substitute u00a0 within a JSON document

I have a JSON file structured like this: [ { "content": ["<p style=\"text-align:justify;\"> This is content1</p>"], "title" : ["This is\u00a0title 1"] }, { "content": ["<p style=\"text-a ...

Sorting data in a Footable table by an unfinished line

My data table contains various lines like: 97.5%, 10/30, 41 RPM, 3.6 seconds, $4750, $100 When I set the type data-type = "number" in the rows, everything is stripped except for the numbers. However, I need the output to remain complete as shown in the ex ...

The .prepend() method receives the variable returned by ajax and adds it

I'm facing a challenge with adding a dynamic select box to a string within my .prepend() function. The options in the select box are subject to change, so hard coding them is not an option. To tackle this issue, I am using an AJAX call to construct th ...

Having trouble connecting my CSS Bootstrap file in VS Code

Having trouble linking my bootstrap file to my HTML in VS Code. Despite successfully adding the link, it does not seem to be working. https://i.sstatic.net/Yt7VH.jpg ...

Using the <audio> tag in HTML5 on Android devices

Exploring discussions on Android's support for the <audio> tag has been enlightening. Despite attempts on a Nexus One running Android Froyo 2.2, it seems playing audio remains elusive. As indicated by www.html5test.com, while the tag is support ...

Connecting within a webpage without the use of the pound sign

I have a simple question as I am relatively new to programming, having only started about two weeks ago. I want to create a menu with three options: menu1, menu2, and menu3. My question is how can I create a link without using the hashtag (#)? For exampl ...

Eliminate the spacing between elements when they are in close proximity

I've noticed there is a margin between the buttons as shown below: .button + .button { margin-left : 1rem; } The buttons are contained within a <div class="row">, which will stack on top of each other on smaller screens: https://i.s ...

CrispyForms: FormHelper - Easily move the </form> tag to a different location and manage multiple forms from a single model

When utilizing FormHelper and invoking the Form using {% crispy form %}, it generates a Form wrapped within <form> tags. However, my Template is structured into two columns. The first column displays the dynamically generated {% crispy form %}. The ...

Utilizing Flask to insert data into a MySQL database table

Hey there, I'm running into some trouble with inserting values into my database. While I can successfully log in using the same method on the sign-up page, I've tried various options without success. Below is my Python code: from flask import F ...

How can I achieve the same dog-ear effect with CSS that is seen on Twitter?

Adding a unique touch to your website can be achieved by incorporating a triangle 'dog-ear' effect to the corners of divs. On Twitter, this effect is visible when you retweet or favourite a tweet, as a little coloured triangle with an icon appear ...

Arranging multiple Label and Input fields in HTML/CSS: How to create a clean and

I'm struggling with HTML and CSS, trying to figure out how to align multiple elements on a page. I've managed to line up all the rows on the page, but for some reason, the labels are appearing above the input fields when I want them to appear be ...

Unable to integrate Django into HTML

Having trouble using Django variables within HTML code Here is the code snippet: models.py from django.db import models from django.urls import reverse # Define models here. class Post(models.Model): title = models.CharField(max_length=255) slug ...

Is there a way to eliminate overflow on a section of my CSS page without sacrificing the 100vh height?

My professor requested a section in my project to have its height adjusted to the viewport, however this has created a large gap between that section and the rest of my content. How can I remove the overflow and close the gap? <main> <sect ...

AngularJS - A Guide to Detecting Window Resize and Orientation Changes in Landscape and Portrait Modes

I have attempted various suggestions from Stack Overflow, but none of them have been successful. Essentially, I am seeking to update (re-render) a custom directive whenever the window size changes. This is my code: angular.module('dynamicSlideBox&ap ...

What is the best method to create a transparent first row and all columns using css?

Is there a way to implement this design using HTML and CSS? https://i.sstatic.net/RjD6l.jpg Keep in mind that the first row and columns in the first row should be transparent. ...

The font rendering in Safari appears to have distinct differences compared to other web browsers

My concern is related to the HTML tag below: <a href="/partner-team/team" class="button button__style--1">MEHR</a> This is how the CSS appears: a { text-decoration: none; } .button { padding: 0.2rem 4rem; curso ...

What is the best way to save data in order to effectively showcase a collection of images that together form a single entity in a game

Apologies for the unclear title, I struggled to find the right words. Recently, I delved into the world of 2D game development and was amazed by the capabilities of HTML5's Canvas element. Currently, I am working on my first basic project to grasp th ...