Animating CSS3 keyframes on backgrounds with a full width and height dimension

I'm currently working on animating the background of a full-width and full-height element using a simple CSS3 animation that steps through a sprite image.

Here's what the animation code looks like:

.play-intro{animation: play 2s steps(6);}
@keyframes play {
from { background-position:    0 0 ; }
to { background-position:      -7800px 0 }
}

The problem I'm encountering is that each sprite change is visible, indicating that the animation isn't functioning correctly. I suspect this issue might be related to the background-size:cover property. Any suggestions on how to fix this?

To help illustrate the issue, I've created a fiddle: http://jsfiddle.net/QKwjM/1/

You can also view the fullscreen version of the fiddle to see the problem more clearly: http://jsfiddle.net/QKwjM/1/embedded/result/

Answer №1

When implementing

background-size: cover;

the background size becomes flexible based on the available space, causing disruptions in the animation.

To ensure consistency with a keyframe set at -7800px, the background-size-x should be precisely that value:

background-size: 7800px 701px;

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

"Upon the page loading, a flickering effect can be seen in the div that

I'm trying to avoid this issue. Whenever I use ng-repeat, it initially displays everything inside the div along with empty scopes for a brief moment before loading the data and showing it normally. I want to eliminate this flicker upon page load but c ...

Attempting to override the default system appearance in CSS for ASP.NET is ineffective

I am currently working on creating a CSS style that can modify the appearance of a dropdown control to look like a label, while allowing another dropdown on the same page to retain its default appearance. To achieve this, I am using a custom attribute with ...

Tips on how to stop label text from wrapping onto a new line and only show one line

Working with asp.net mvc, I am encountering an issue where the label text is displaying on two lines instead of one. The expected behavior is for it to appear on a single line. I need the label text to display without wrapping to a new line. For example, ...

Update the font in the pagination links

I'm attempting to modify the font of the pagination on my website. View image 1 Despite using a website builder, I couldn't find the option to change the font, so I resorted to inspecting the code to locate the correct class or id in order to u ...

Webpack will only load images that are referenced within CSS files, and it will not load images that are referenced within

Within my dist folder, you will find index.html, contact.html, index.js, contact.js, and two images referenced by my css as background images. For example: background-image: url("../images/prairie.jpg"); These are the only items in my dist folder. Any o ...

Navbar alignment issue: justify-content-between not functioning properly

The justify-content-between property is not functioning as expected for the navbar. I need the navigation list to expand and cover the entire space with equal spacing between the items. <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-boots ...

Calculate values dynamically when styling material-UI components

Utilizing the Material-UI style to define the class. Now, I aim to adjust the height based on the browser's width. Is there a way to dynamically calculate this within makeStyles() or implement a workaround? This snippet below represents what I am t ...

Creating a dynamic hover drop-down navigation bar in ASP.NET

After successfully creating a navigation bar with hover effects, I am now looking to implement a dropdown list when hovering over the items. Can anyone provide guidance on how to achieve this? Below is the current code snippet I am working with: <ul c ...

The functionality of the star ratings is not working properly when attempting to click on them

I am encountering an issue with my rating system code that uses Font Awesome stars in a form. When I click on it, the system does not function as expected. My goal is to adjust the code so that the rating system works accurately upon clicking. Below is th ...

Encase the entire section following cloning with JQuery

Make sure to check out the jsfiddle demo linked below before proceeding: JSFIDDLE I need to transform the original structure as shown below: <div class="out"> <a>im here</a> <a>to save</a> <a>our</a> ...

What is the best way to align the content of a <ul> in the center while keeping the text left-aligned and setting a max-width

UPDATE: Including an image for better visualization: [![Check out the image link][1]][1] To understand more clearly, refer to this fiddle: https://jsfiddle.net/c7jazc9z/2/ Currently, I have a list with items aligned to the left. The goal is to center th ...

What steps can be taken to ensure that an element does not exceed the boundaries of its grandparent container?

I am facing a unique scenario where I have a div with dynamic content, and inside it is another div containing a growing list. The challenge is to allow the internal div to expand until the root div reaches its maximum height, after which overflow should ...

Tips for implementing a fully responsive left-side menu using Twitter Bootstrap 4.2

I'm attempting to design a layout featuring a top navbar and a collapsible left menu. On medium-sized screens or smaller, the left menu should remain hidden. However, it needs to occupy the full height of the page at all times, regardless of its actu ...

Placing one image on top of another in an email layout

Is there a way to position an element in any email template? I need to place an image over another one, which can only be done by either positioning it absolutely or giving it a margin. However, I've heard that Google doesn't support margin and p ...

Combining the elements p and div on a single line

I've designed a card layout with 3 rows containing a paragraph and a div element each. I want both elements in each row to be displayed on the same line. How can I achieve this? Sample HTML: <div class="user_card"> <div class="skills"&g ...

Combine all the HTML, JavaScript, and CSS files into a single index.html file

So here's the situation - I am utilizing a C# console application to convert four XML files into an HTML document. This particular document will be circulated among a specific group of individuals and is not intended to be hosted or used as a web app; ...

Anyone able to solve this mysterious CSS alignment problem?

I have a search bar with two image buttons on a webpage I designed using ASP.NET. When I view the page in Internet Explorer 8, Google Chrome or Opera, I noticed that the textbox and image buttons are not aligned properly. The buttons seem to be positioned ...

Ninja Flip ComboButton

I am looking to enhance the functionality of a toggle button within a web application that was developed using the JS Dojo API. Currently, the button is utilizing dijit.form.ToggleButton, but I need it to include an additional feature for a dropdown menu w ...

Using the CSS width and height properties to manipulate the background-image property

Could someone help me with adjusting the title to better represent this question? Is there a way to determine the width/height of a background-image and assign it directly to the width/height property in CSS without using JavaScript? To clarify, here&apo ...

What methods can be used to identify the specific Router component being rendered in React?

I am currently working with a Navbar component that I want to render with different CSS styles using styled-components based on the route of the component being rendered. How can I determine whether that component is being rendered or not? const NavbarCont ...