Troubleshooting: @keyframes not functioning properly in slideshow

Having trouble getting my image slider to function properly. I want to use it as a header for my page, but the images are not sliding like they should. I've attempted using prefixes for Chrome, but that hasn't solved the issue.

<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<div class ="slider">
  <figure>
    <img src="slider-test-image-1.jpg" >
    <img src="slider-test-image-2.jpg" >
  </figure>
</div>
<body>
</body>
<html>

This is the CSS

.slider{
margin:0 auto;
padding:0;
overflow: hidden;
position:relative;

}

.slider figure{
margin:0 auto;
padding: 0;

width:200%;
-webkit-animation: 5s slidy infinite;
position:relative;
left:0;

}
.slider figure img{
margin:0 auto;
padding: 0;
overflow: hidden;
float:left;
width:50%;

position:relative;
}

@-webkit-keyframes slidy{
0%{
  -webkit-left:0%;
}
45%{
  -webkit-left:0%;
}
50%{
  -webkit-left:-100%;
}
100%{
  -webkit-left:-100%;
}

}

Answer №1

It seems you have only set the @-webkit-keyframes and -webkit-animation, but you need to also include @keyframes and animation (without the -webkit-). Additionally, make sure you are not missing prefixes for the left, right, top, or bottom CSS properties. Also, there is a typo with "infinate" instead of infinite. Here is the corrected code:

.slider {
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.slider figure {
  margin: 0 auto;
  padding: 0;
  width: 200%;
  animation: 5s slidy infinite;
  -webkit-animation: 5s slidy infinite;
  position: relative;
  left: 0;
}

.slider figure img {
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  float: left;
  width: 50%;
  position: relative;
}

@-webkit-keyframes slidy {
  0% {
    left: 0%;
  }
  45% {
    left: 0%;
  }
  50% {
    left: -100%;
  }
  100% {
    left: -100%;
  }
}
<div class ="slider">
  <figure>
    <img src="slider-test-image-1.jpg" >
    <img src="slider-test-image-2.jpg" >
  </figure>
</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

Hiding content: impossible to change. Acting independently?

Currently, I am attempting to showcase a count-down feature on my website (which is currently in localhost so it cannot be linked). However, I have encountered a very peculiar issue. I suspect that the JavaScript may be causing the display to not appear. ...

picker and calculator for selecting date ranges

I'm currently working on a hotel booking form where prices are calculated based on the number of adults, seniors, and students. I'm trying to add a date range picker feature that will determine the total cost depending on the selected number of d ...

The issue with the Material UI Drawer component is that it is casting a shadow even when

Having some trouble with the Material UI Drawer component. Whenever I try to display it on my webpage, it automatically focuses on the inner div, adding a shadow or border if the focus is anywhere else. Does anyone know why this shadow appears and how to r ...

What benefits does utilizing unordered lists provide in navigation bars?

Throughout my research, I have come across numerous tutorials detailing the process of creating a navigation bar. They often begin by adding an unordered list and then proceed to remove the default styling such as bullet points and margins from both the ...

Connect Angular Elements with Polymer 1.0

I have a unique custom element: <my-element options='{{myOptions}}'></my-element> When using this, the ready callback in the web component only receives {{myOptions}} for the options property. Despite trying various tools, none seem ...

Encountering an issue with usememo in React js?

I'm currently experimenting with the useMemo hook in React JS. The goal is to sort an array of strings within a function. However, when I return the array from the function, only the first element is being returned. Can someone please assist me in ide ...

Transitioning from container to container-fluid class for tablets using bootstrap

I'm currently utilizing the container class in my project and I'm looking for an elegant way to switch it to container-fluid or adjust the width to resemble container-fluid when the website is viewed on a tablet, so it utilizes the full width of ...

The background color in the HTML file remains unchanged

Hello everyone, this is my debut post here. I can't seem to figure out why the background color isn't changing for me. Even though I have applied the bg color property, it's not taking effect as expected. <body bgcolor="#f0ffff"> T ...

Changing the Parent div style based on checked radio input in Reactjs

As a Reactjs beginner, I am looking for assistance in changing the background color of a faculty item (.faculty) to red when the respective radio input is checked. This should be achieved using the onChange method in Reactjs. Thank you in advance for you ...

Upon refreshing the page, Vuex encounters an issue where it is unable to read

My website has a Navbar component that utilizes values from the Vuex store. Prior to entering each route, I trigger a dispatch from Vuex as shown below: router.beforeEach((to, from, next) => { //... store.dispatch("updateUserData"); ...

Resize the p-accordion within a p-splitter using PrimeNG programmatically

Please find the code for my component below: In this component, I have a p-splitter that is divided into 3 sections. Each section contains a p-accordion, which in turn includes a p-table. <div class="card w-full"> <p-splitter [p ...

Place two divs within a parent div, with one div aligned at the top and the other at the bottom

Here is the code snippet I am working with: <div id="container"> <div id="1"> div 1</div> <div id="2"> div 2</div> </div> I am looking to rearrange the order so that div 1 is positioned at the top and div 2 is ...

I'm looking to create a JavaScript function that will extract each element from a div and then apply a corresponding CSS block to activate it

My goal was to create this function using Flask, but it seems that only JavaScript is capable of achieving it. This is my first attempt at coding it. Here's the code snippet: const navSlide2 = () => { const burger = document.querySelector(&apos ...

Modify the color of the dropdown list title within a designated area

I am looking to customize the font color of specific text within a dropdown list. The two options in the list are: 1. Doctor Name 1 (Discount 10%) and 2. Doctor Name 2 (Discount 15%). I would like to change the font color of only (Discount 10%) (to red) ...

Innovative sound system powered by React

I am working on implementing a music player feature on a website where users can select a song and have it play automatically. The challenge I am facing is with the play/pause button functionality. I have created all the necessary components, but there see ...

Reveal the hidden div by sliding it up from the bottom

I have a container with brown branches resembling the image, and I'm looking to hide it. When a button is clicked, I want it to reveal from the bottom to the top, almost like it's being unmasked. I've ruled out a typical bottom-up slide anim ...

Seeking assistance with a basic script for a side menu

Link to customize the submenu. I am having trouble adjusting the width of the main menu to 300px and the sub-menus to 150px. Currently, both have the same width and I can't seem to change it. Can someone assist me? Below is the code I am currently u ...

Code formatting for MVC HTML layout in C#

When working with asp.net mvc views, I like to incorporate C# logic that handles layout in the following manner: <% if (Model.People.Count > 0 ) { %> <% foreach (var person in Model.People) { %> ... <% }} else { %> & ...

padding issues with spacing between table elements

I currently possess a table. <table style="margin-left: 20px" class="tg"> <tbody> <tr> <td class="tg- 0lax">Inquiry 1</td> ...

What is the method for accessing a local CSV file using client-side Javascript?

I need to use client-side JavaScript to read data from a local csv file. The HTML code imports a JavaScript file located in a different folder using a script tag. Here's the content of the JavaScript file: $.ajax({ type: "GET", url: "./../.. ...