how can I avoid this css3 background loop jump? - animation

I've been experimenting lately with some css3. What I'm trying to do is make a background image slide left and repeat seamlessly to give the effect of an infinite background animation (kind of like how they do backgrounds in old cartoons, where it's just looping over and over...). The problem that I'm facing with this css3 is that once the animation is complete, it snaps back into it's starting position. See here: my blog. The background of the entry titled "super sluggy" will snap back into place after the animation has completed. I've been looking through w3schools for the answer, and google and even related stack questions but I can't find the solution anywhere. Here is my code:
#keyframes l_2_r
{
from {background-position: top left;}
to {background-position: top right;}
}
#-moz-keyframes l_2_r
{
from {background-position: top left;}
to {background-position: top right;}
}
#-webkit-keyframes l_2_r
{
from {background-position: top left;}
to {background-position: top right;}
}
#-o-keyframes l_2_r
{
from {background-position: top left;}
to {background-position: top right;}
}
#sluggy_div{
background: url('../imgs/sluggy-bg.jpg') repeat-x;
animation: l_2_r 7s linear infinite;
-moz-animation: l_2_r 7s linear infinite;
-webkit-animation: l_2_r 7s linear infinite;
-o-animation: l_2_r 7s linear infinite;
}
the background itself is seamless if repeated along the x axis, however when animated the transition is a quick snap and I'd like it to be seamless or not noticable to the user I should say.
Does anyone know how to fix this? Thanks!

The easiest solution I came up with is to simply animate the background-position in the x direction from 0 to a position that's effectively the negative of its width (in this case -1000px):
#-webkit-keyframes l_2_r {
from {background-position: 0 0;}
to {background-position: -1000px 0;}
}
#sluggy {
width: 560px;
height: 374px;
border: 1px solid #f90; /* just for visibility */
background-image: url(http://digitalbrent.com/imgs/sluggy-bg.jpg);
-webkit-animation: l_2_r 7s linear infinite;
}​
JS Fiddle (Webkit-vendor-prefix only) demo.
And this seems, in Chromium 18, to work fine. Hopefully you don't mind my using your actual images in the demo, but I didn't have any suitable images with which to test.

Related

CSS3 Transition on absolute positioned element disappears under Canvas, Embed

I have a menu bar with drop downs that use absolute positioned elements. On hover, the elements fade in using CSS3 transitions. Note, we're using a heavily modified version of Zurb's Foundation 4.
.has-dropdown {
.dropdown {
z-index: 90;
opacity: 0;
transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
&.hover .dropdown {
opacity: 1;
}
}
We have an instance of an OpenSeadragon image, using the html5 <canvas> option on one page, and a YouTube <embed> on another. The YouTube embed has the wmode="Opaque" and &wmode=transparent code on them to force them to respect z-index as outlined here. Both the embed and the canvas and their parent elements are set to z-index: 2; position: relative;
The issue we're running into is that the .dropdown element drops behind the <canvas> and the <embed> once the transition is complete. This seems to happen mostly on Chrome. As soon as we mouse over any of the menu items, the menu pops back in front.
How do we fix this?
Removing the transition fixed the issue. The menu popped right in front of both the canvas and the embed and stayed there.
This didn't solve the issue with having a css transition, though. In order to fix that, I applied a webkit-transform: translate3d(0px, 0px, 0px); to the .dropdown:
.has-dropdown {
.dropdown {
-webkit-transform: translate3d(0px, 0px, 0px);
opacity: 0;
transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
&.hover .dropdown {
opacity: 1;
}
}
Now I have a transition that appears over the top of the embed and the canvas. Happy days!
Just add z-index to higher number like:
z-index: 1111;
If needed add:
pointer-events: none;

CSS3 background-image slider: animate and background-size

I am creating an image-slider by using CSS only. I am almost done coding, but I can't figure out what I have to do so that the images don't scale unproportional while sliding. I still want them to fill the div and not to be stretched at 100% and I also don't want to cut the images because I want (you) to figure out a way to do this :)
Here's a part of my code:
div#transition3 {
width:480px;
height:360px;
-webkit-animation:trans2 12s;
-webkit-animation-iteration-count: infinite;
-webkit-box-sizing:border-box;
-webkit-background-origin:border-box;
background-scale:fill;
}
#-webkit-keyframes trans2 /* Safari and Chrome */
{
0% {background:url('../img/1.jpg') no-repeat top left;}
10% {background:url('../img/1.jpg') no-repeat top left;}
20% {background:url('../img/2.jpg') no-repeat top left;}
30% {background:url('../img/2.jpg') no-repeat top left;}
40% {background:url('../img/3.jpg') no-repeat top left;}
50% {background:url('../img/3.jpg') no-repeat top left;}
60% {background:url('../img/4.jpg') no-repeat top left;}
70% {background:url('../img/4.jpg') no-repeat top left;}
80% {background:url('../img/5.jpg') no-repeat top left;}
90% {background:url('../img/5.jpg') no-repeat top left;}
100% {background:url('../img/1.jpg') no-repeat top left;}
}
Here's a fiddle: http://jsfiddle.net/qDmS8/3/.
I hope you know what I mean and be able to help me.
Thanks in advance!
It's not possible to do it the way I wanted to.
The best way to do this is to create containers for each image, then assign CSS transitions to them as seen on http://tympanus.net/Tutorials/CSS3FullscreenSlideshow/index.html

Background css animation not working at firefox

i have some css animated button.
.bottom_panel ul li.bottom_panel_button_04 {
background: url('../img/bottom_panel_icons/ap_bottom_panel_back_button_01_131.png') center center no-repeat;
-webkit-animation: myfirst 2s linear infinite;
-moz-animation: myfirst 2s linear infinite;
-ms-animation: myfirst 2s linear infinite;
-o-animation: myfirst 2s linear infinite;
animation: myfirst 2s linear infinite;
}
#-moz-keyframes myfirst {
0% {background: url('../img/bottom_panel_icons/ap_bottom_panel_back_button_01_131.png') center center no-repeat;
}
50% {background: url('../img/bottom_panel_icons/ap_bottom_panel_back_button_01_131_on.png') center center no-repeat;
}
100% {background: url('../img/bottom_panel_icons/ap_bottom_panel_back_button_01_131.png') center center no-repeat;
}
}
On Chrome everything is fine but firefox can't fire this animation... what is wrong?
Replace #-moz-keyframesto #keyframes and add #-webkit-keyframes for Saffari and Chrome (and all Chromium-based browsers)
You can see an example here.
And here is the link to your (working) example.

CSS3 Rotating Animation with delay

Ok, so I have this rotating CSS3 animation (with a repeating timeout in the animation) almost working but I'm getting this really weird behavior where the animation seems to "jump" backward as it's animation.
I have a demo here in JS Fiddle (EDIT - Please excuse the long delay, it's a necessary part of the animation - a long timeout): http://jsfiddle.net/3mnMz/1/
For posterity, here is my CSS
#logo { position: relative; float: left; width: 175; height: 75px; margin: 0 0 16px; padding: 0; }
#-webkit-keyframes rotate {
0%, 65%, 75%, 100% {
-webkit-transform: rotate(0deg);
}
70% {
-webkit-transform: rotate(360deg);
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-delay: 3s;
}
}
#logo span.star
{
-webkit-animation-name: rotate;
-webkit-animation-duration: 6s;
-webkit-animation-iteration-count: infinite;
}
#logo span.star { width: 84px; height: 84px; background: url('../img/logo_star.png') no-repeat left top; position: absolute; top: -8px; right: -20px; display: block;
}
Can someone shed some light on the subject?
I'm not sure about what you're trying to achieve, but the reason why it's rotating back and forth is because you're stating at keyframe 70% that the rotation is 360, then at 75 that it's rotation 0, so it goes back to the original state.
The animation properties should also be stated within the span.star element, not within the keyframes.
Here is a demo:
http://jsfiddle.net/3VrjE/

Why do CSS3 animations behave strangely when used in conjunction with CSS3 transitions?

See this fiddle for an example of what I mean or view this code.
test
a{
background-color:#ccc;
transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-webkit-transition: all 1s ease;
}
a:hover{
background-color:#888;
}
a{
-moz-animation-duration: 3s;
-moz-animation-name: move;
-moz-animation-iteration-count: infinite;
-moz-animation-direction: alternate;
}
#-moz-keyframes move {
from {
margin-left: 0px;
}
to {
margin-left: 50px;
}
}
The animation occasionally jumps about or changes speed, particularly when you hover over it... I have tried running the animation on its own (without the transition defined) and it runs smoothly and as expected. I have run the transition on its own and it works as expected. The combination seems to cause the problem.
Could be a Firefox implementation bug? I'm running Firefox 6.0.1, Ubuntu 11.04.
You need to replace 'all' by 'background'. Then it works fine. I think when you hover it will transition all styles, so also the current-margin-left to the new margin-left, which is the same, so the margin doesn't change for the duration of the transition. Afterward the animation takes precedence again and you see the jump.

Resources