What is causing the disappearance of the images and animation when a class is added to the final column?

My goal is to create a continuous animation loop with 6 images.

However, when I try to add the 6th image and include the "poster" class, none of the images appear on the screen. If I skip adding the "poster" class to the 6th image, the first 5 images display and animate as intended.

I'm puzzled by this behavior and not sure why it's happening.

In the code provided below, you can see that the "poster" class is excluded from the sixth column, which makes the code work properly. But as soon as I apply that class, the animation stops functioning.

(Please note that I am using bootstrap 5, but the issue at hand seems unrelated to the framework since the problem persists even without it)

@keyframes moves {
  to {
    background-position: -100vw 80%;
  }
}

.galeria {
  position: relative;
  overflow: hidden;
}

.poster {
  position: absolute;
  animation: moveAcross 6s linear infinite;
}
.poster-1 {
  animation-delay: -0s;
  animation-duration: 6s;
}
.poster-2 {
  animation-delay: -1s;
  animation-duration: 6s;
}
.poster-3 {
  animation-delay: -2s;
  animation-duration: 6s;
}
.poster-4 {
  animation-delay: -3s;
  animation-duration: 6s;
}
.poster-5 {
  animation-delay: -4s;
  animation-duration: 6s;
}
.poster-6 {
  animation-delay: -5s;
  animation-duration: 6s;
}

@keyframes moveAcross {
  0% {
    left: -300px;
  }
  100% {
    left: 110%;
  }
}
<div class="row justify-content-center">
    <div class="galeria">
        <div class="col poster poster-1">
            <img src="images/posters/poster1.jpg" class="img-fluid" />
        </div>
        <div class="col poster poster-2 ">
            <img src="images/posters/poster2.jpg" class="img-fluid" />
        </div>
        <div class="col poster poster-3">
            <img src="images/posters/poster3.jpg" class="img-fluid" />
        </div>
        <div class="col poster poster-4 ">
            <img src="images/posters/poster4.jpg" class="img-fluid" />
        </div>
        <div class="col poster poster-5">
            <img src="images/posters/poster5.jpg" class="img-fluid" />
        </div>
        <div class="col poster-6">
            <img src="images/posters/poster6.jpg" class="img-fluid" />
        </div>
    </div>
</div>

Answer №1

Functioning flawlessly with the assigned .poster class in the sixth column, regardless of Bootstrap 5 being present or not.

Edit: To add an extra hidden poster at the end, just ensure that the last poster does not include the .poster class and it will work smoothly :)

<div style="visibility: hidden;">
    <img src="https://soft.com.mx/test/images/posters/poster6.jpg" class="img-fluid" />
</div>

@keyframes moves {
to {
    background-position: -100vw 80%;
}
}

.galería {
position: relative;
overflow: hidden;
}

.poster {
position: absolute;
animation: moveAcross 6s linear infinite;
}
.poster-1 {
animation-delay: -0s;
animation-duration: 6s;
}
.poster-2 {
animation-delay: -1s;
animation-duration: 6s;
}
.poster-3 {
animation-delay: -2s;
animation-duration: 6s;
}
.poster-4 {
animation-delay: -3s;
animation-duration: 6s;
}
.poster-5 {
animation-delay: -4s;
animation-duration: 6s;
}
.poster-6 {
animation-delay: -5s;
animation-duration: 6s;
}

@keyframes moveAcross {
0% {
    left: -300px;
}
100% {
    left: 110%;
}
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="593b36362d2a2d2b3829196c7769776b">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<div class="row justify-content-center">
    <div class="galeria">
        <div class="col poster poster-1">
            <img src="https://picsum.photos/300/300?random=1" class="img-fluid" />
        </div>
        <div class="col poster poster-2 ">
            <img src="https://picsum.photos/300/300?random=2" class="img-fluid" />
        </div>
        <div class="col poster poster-3">
            <img src="https://picsum.photos/300/300?random=3" class="img-fluid" />
        </div>
        <div class="col poster poster-4 ">
            <img src="https://picsum.photos/300/300?random=4" class="img-fluid" />
        </div>
        <div class="col poster poster-5">
            <img src="https://picsum.photos/300/300?random=5" class="img-fluid" />
        </div>
        <div class="col poster poster-6">
            <img src="https://picsum.photos/300/300?random=6" class="img-fluid" />
        </div>
    </div>
</div>

Answer №2

Issue Resolved...

By simply eliminating the position: relative; property from the galeria class, everything is now functioning smoothly. Interestingly, no rules are necessary for this particular class.

Revised CSS Code:

.poster {
  position: absolute;
  max-width: 20vw;
  animation: moveAcross 6s linear infinite;
}
.poster-1 {
  animation-delay: -0s;
  animation-duration: 6s;
}
.poster-2 {
  animation-delay: -1s;
  animation-duration: 6s;
}
.poster-3 {
  animation-delay: -2s;
  animation-duration: 6s;
}
.poster-4 {
  animation-delay: -3s;
  animation-duration: 6s;
}
.poster-5 {
  animation-delay: -4s;
  animation-duration: 6s;
}
.poster-6 {
  animation-delay: -5s;
  animation-duration: 6s;
}

@keyframes moveAcross {
  0% { left: -30vw; }
  100% { left: 110%; }
}

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

Utilizing the dynamic flair with React's map functionality

In my display area, which is a div element, I have rendered some text using spans. I utilized the map function to render the text from an array. The issue arises when I apply a color class to the span elements within the map function, causing all text to ...

Generate a dynamic list item by utilizing two file paths with JQuery

Alright, let me explain this as clearly as possible My goal is to create a jQuery function that will generate a list from images stored in two different folders. The result I am looking for is a list containing up to 30 images. <div id="box"> & ...

Trouble with CSS table background display in Outlook

I am experiencing issues with an HTML table in an email template: <table id="x_formHeaderTable" style="width:100%; margin:0; padding:0; background-color:#FCE68D; border-style: solid; border-color: #000000;"> <tbody> <tr> &l ...

The collapsible toggle feature is currently not working as intended

I have tried looking for solutions but have not been successful. My apologies for asking what may seem like a simple question. The toggle button is not expanding to show the menu items when clicked. It works fine on the "home" page but not on the linked pa ...

Retrieve text from an element using jQuery when triggering "mouseenter" on a different element

Is there a way to retrieve the text from an element while simultaneously triggering a 'hover' action on another element? Here is an illustration: I am trying to gather all available colors, but the color names are only visible upon hovering ove ...

Troubleshooting problems with Z-Index div hover overlay on [windows] and Webkit browsers (Safari, Opera, etc)

Note: This issue is specific to Windows Webkit and does not affect Macs I am attempting to create a grid with fixed-size cells containing background images. When hovered over, the background image changes and the cell's height increases, overlaying t ...

PhoneGap redirect page feature

When using PhoneGap, I have encountered an issue with opening internal links. Despite using the href tag in my HTML, I am unable to load the webpage. Can someone please advise on how to properly redirect from one HTML page to another within PhoneGap? ...

What is the best way to include a colored square before multiple items on a list?

Is there a way to customize list items with colored squares before the text? I've been searching for a solution, but haven't found it yet: http://www.w3schools.com/cssref/pr_list-style-type.asp Although they don't necessarily need to be l ...

Limit the use of the angular directive to only one instance

Hey there, I'm currently working with a directive that captures global events like mousedown, mouseup, and scroll on the body tag. I'm interested to know if there's a way to restrict the usage of an angular directive so it can only be used o ...

There seems to be an issue with the functionality of Angular Material in Angular9

I've encountered an issue with the material form field, even after importing the necessary modules. Surprisingly, there are no console errors to provide more insight into the problem. { "name": "online-shop", "version": "0.0.0", "scripts": ...

Sending you to a new page and popping up an alert

I have set up an HTML form for user registration and after a successful registration, I want users to be redirected back to my index.html page with an alert confirming their successful registration. Currently, the alert is working but it opens in a blank ...

The mobile site is extending beyond the width of the device screen

After creating this single web page and testing it on my mobile device, I noticed an issue. When I swipe to the left, the website's width shifts slightly, as if the edges are not fully contained within the screen. This problem only occurs on Safari, n ...

Is it normal for e.target.result to only work after two or three tries?

Attempting to resize an image on the client side before sending it to the server has been challenging for me. Sometimes, the image does not align correctly with the canvas used for resizing. I have noticed that I need to send the resized image at least tw ...

What are some tips for using CSS display grid to effectively showcase my HTML content?

Visit my About Me page with custom menu styling Any tips on aligning the body with the grid function to achieve this particular design? ...

Angular.js <div ng-include> not expanding to the full height of the viewport

My goal is to create a single-page app with a scrolling effect using Angular.Js. Each ng-include section within the <div class="viewport" ng-include="'views/file'" ng-controller="MainCtrl"></div> should fill the viewport entirely. How ...

The placement of the breadcrumb trail is not in the right position

My website includes a menu and breadcrumbs. The menu consists of two submenus: Design Services, Design Portfolio, Design Fees, About Us, Contact Us, Design Resources, Design Vacancies, and Terms. Clicking on Design Services reveals Graphic Design, Logo Des ...

Setting up VideoJS Flash backup

Due to Firefox's restriction on using an .mp4 file in the <video> tag, I am required to utilize the Flash fallback option on my VideoJS player. When it comes to Chrome, Safari, and IE, I can customize my VideoJS player via JavaScript to perform ...

The combination of list-style-type and display:inline is ineffective

Many questions have been asked in different areas about this issue, but none of the answers I found were able to solve my problem. My challenge lies in creating a navigation menu where I can't remove the list style or display it inline. Here is the HT ...

What are the steps to create a shadow effect on a bar chart in ChartJs?

Currently, I am utilizing version 3.9 of chartjs to construct a bar chart. My goal is to incorporate a shadow effect on the bars resembling the image in this link: https://i.sstatic.net/SGIrO.png Despite my efforts, I have not been able to locate instruc ...

Leveraging Angular and HTML to efficiently transfer the selected dropdown value to a TypeScript method upon the user's button click

I am experiencing difficulty accessing the .value and .id properties in {{selectItem}} in order to send them back to the typescript for an HTTP post at a later time. Although there are no specific errors, I have encountered exceptions and have tried search ...