CSS3 animation different on chrome and others - html

Here is in fiddle an example of the problem that I'm facing. This animation has different behavior in different browsers. I need to make all work as Chrome. Tested on Chrome and Firefox.
HTML:
<div class='wrap'>
<div class='animate'></div>
</div>
CSS:
#keyframes test {
0% {
left: 0;
right: inherit;
width: 0;
}
10%{ width: 100%;}
49%{ width: 100%;}
59% {
left: inherit;
right: 0;
width: 0;
}
100% { width: 0;}
}
#-webkit-keyframes test {
0% {
left: 0;
right: inherit;
width: 0;
}
10%{ width: 100%;}
49%{width: 100%;}
59% {
left: inherit;
right: 0;
width: 0;
}
100% {width: 0;}
}
.wrap{
height: 10px;
position: relative;
width: 100%;
}
.animate{
background: #000;
height: 10px;
position: absolute;
top: 0;
-webkit-animation: test 6s infinite;
animation: test 6s infinite;
}

You can use this solution jsfiddle.net/vVGmR/2 - the only one css rule is animated here and it works. Tested on IE10, latest Firefox, Opera and Chrome
#keyframes test {
0% {left: -100%;}
10% {left: 0;}
49% {left: 0;}
59% {left: 100%;}
99.99% {left: 100%;}
100% {left: -100%;}
}
#-webkit-keyframes test {
0% {left: -100%;}
10% {left: 0;}
49% {left: 0;}
59% {left: 100%;}
99.99% {left: 100%;}
100% {left: -100%;}
}
.wrap{
height: 10px;
position: relative;
width: 100%;
overflow: hidden;
}
.animate{
background: #000;
height: 10px;
position: absolute;
top: 0;
width: 100%;
-webkit-animation: test 6s infinite;
animation: test 6s infinite;
}

Related

a Form on a slider (HTML & CSS)

So i have a form, but i want it on my slider. The form is in a div and the slider is aswell.
This is the HTML
<div id="slider" >
<figure>
<img src="slider1.png" >
<img src="allevoertuigen.png">
<img src="THEORIECURSUS.png">
<img src="PAKKETTEN.png">
<img src="CONTACT.PNG">
</figure>
</div>
This is the CSS
#keyframes slider {
0% {
left: 0;
}
20% {
left: 0;
}
25% {
left: -100
}
45% {
left: -100%
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -300%
}
95% {
left: -300%;
}
100% {
left: -400%;
}
}
#slider {
overflow: hidden;
}
#slider figure img {
width: 20%;
float: left;
}
#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 20s slider infinite;
}
Form is a div with a form tag with labels and submit buttons in it. IF you guys still need the Form code too, here is the gyazo of it. :
https://gyazo.com/1280234e8f37ae6bd8d01bb265ad61d4
I`ve found some things missing in the beginning of the css
0% {left: 0;}
20% {left: 0;}
25% {left: -100;}
45% {left: -100%;}
50% {left: -200%;}
70% {left: -200%;}
75% {left: -300%;}
95% {left: -300%;}
100% {left: -400%;}
Maybe is just that.

make a div screen size dependent

I'm working on an app with Ionic framework and I'm still a novice in css. I created a images slider with timer and but the size of it is fixed. However, I would like to change it to be depends on the screen size and resolution.
This is the html content:
<ion-content>
<div class="container">
<div id="content-slider">
<div id="slider">
<div id="mask">
<ul>
<li id="first" class="firstanimation">
<a href=#><img src="../img/coffe_and_sweet_sale.jpg"/></a>
<div class="tooltip"><h1>text 1</h1></div>
</li>
<li id="second" class="secondanimation">
<img src="../img/pizza_sale.png"/>
<div class="tooltip"><h1>text 2</h1></div>
</li>
<li id="third" class="thirdanimation">
<img src="../img/sandwich_sale.jpg"/>
<div class="tooltip"><h1>text 3</h1></div>
</li>
</ul>
</div>
</div>
</div>
</div>
</ion-content>
In the
style.css
I did something like that:
#slider{
background: #000;
border: 5px solid #eaeaea;
box-shadow: 1px 1px 5px rgba(0,0,0,0.7);
height: 320px;
width: 680px;
margin: 40px auto 0;
overflow: visible;
position: relative;
}
#mask{
overflow: hidden;
height: 310px;
}
#slider ul{
margin: 0;
padding: 0;
position: relative;
}
#slider li{
width: 680px;
height: 320px;
position: absolute;
top: -325px;
list-style: none;
}
#slider img{
width: 680px;
height: 320px;
}
So now it shows the images perfectly but it it doesn't of course fit to any screen.
EDIT 1
I'm adding the style for the slider animation:
#slider li.firstanimation{
animation: cycle 24s linear infinite;
}
#slider li.secondanimation{
animation: cycletwo 24s linear infinite;
}
#slider li.thirdanimation{
animation: cyclethree 24s linear infinite;
}
#keyframes cycle{
0% {top: 0px;}
3.33% {top: 0px;}
26.64% {top:0px; opacity: 1; z-index: 0;}
29.97% {top: 325px; opacity: 0; z-index: 0;}
30.97% {top:-325px; opacity: 0; z-index: 0;}
93.34% {top:-325px; opacity: 0; z-index: 0;}
96.67% {top: -325px; opacity: 0; }
100% {top: 0px; opacity: 1;}
}
#keyframes cycletwo{
0% {top: -325px; opacity: 0;}
26.64% {top: -325px; opacity: 0}
29.97% {top:0px; opacity: 1;}
33.3% {top: 0px; opacity: 1;}
59.94% {top: 0px; opacity: 1; z-index: 0;}
63.27% {top: 325px; opacity: 0; z-index: 0;}
64.27% {top: -325px; opacity: 0; z-index: -1; }
100% {top: -325px; opacity: 0; z-index: -1;}
}
#keyframes cyclethree{
0% {top: -325px; opacity: 0;}
59.94% {top: -325px; opacity: 0;}
63.27% {top:0px; opacity: 1;}
66.6% {top: 0px; opacity: 1;}
93.24% {top: 0px; opacity: 1;}
96.57% {top: 325px; opacity: 0; z-index: 0;}
97.57% {top: -325px; opacity: 0; z-index: -1;}
100% {top: -325px; opacity: 0; z-index: -1;}
}
#slider .tooltip{
background: rgba(0,0,0,0.7);
width: 450px;
height; 60px;
position: relative;
bottom: 85px;
}
#slider .tooltip h1{
color: #fff;
font-size: 24px;
font-weight: 300;
line-height: 60px;
padding: 0 0 0 10px;
}
#slider .tooltip {
transition: all 0.3 ease-in-out;
}
I've added one media query for the height. Here's a link for mediaquery if you want to change something.
As for slider i've fixed the issue now between third and first slide there is a blank slide. I was not sure if it is by design or not. Hope you can fix it if needed.
#slider{
background: #000;
border: 5px solid #eaeaea;
box-shadow: 1px 1px 5px rgba(0,0,0,0.7);
height: 320px;
width: 80%;
max-width: 680px;
margin: 40px auto 0;
overflow: visible;
position: relative;
}
#mask{
overflow: hidden;
height: 310px;
}
#slider ul{
margin: 0;
padding: 0;
height: 320px;
width: inherit;
position: relative;
}
#slider a{
width: 100%;
height: 100%;
}
#slider li{
width: inherit;
height: 320px;
position: absolute;
top: 100px;
list-style: none;
}
#slider img{
width: 100%;
height: 320px;
}
#slider li.firstanimation{
animation: cycle 24s linear infinite;
}
#slider li.secondanimation{
animation: cycletwo 24s linear infinite;
}
#slider li.thirdanimation{
animation: cyclethree 24s linear infinite;
}
#keyframes cycle{
0% {top: 0px;}
3.33% {top: 0px;}
26.64% {top:0px; opacity: 1; z-index: 0;}
29.97% {top: 325px; opacity: 0; z-index: 0;}
30.97% {top:-325px; opacity: 0; z-index: 0;}
93.34% {top:-325px; opacity: 0; z-index: 0;}
96.67% {top: -325px; opacity: 0; }
100% {top: 0px; opacity: 1;}
}
#keyframes cycletwo{
0% {top: -325px; opacity: 0;}
26.64% {top: -325px; opacity: 0}
29.97% {top:0px; opacity: 1;}
33.3% {top: 0px; opacity: 1;}
59.94% {top: 0px; opacity: 1; z-index: 0;}
63.27% {top: 325px; opacity: 0; z-index: 0;}
64.27% {top: -325px; opacity: 0; z-index: -1; }
100% {top: -325px; opacity: 0; z-index: -1;}
}
#keyframes cyclethree{
0% {top: -325px; opacity: 0;}
59.94% {top: -325px; opacity: 0;}
63.27% {top:0px; opacity: 1;}
66.6% {top: 0px; opacity: 1;}
93.24% {top: 0px; opacity: 1;}
96.57% {top: 325px; opacity: 0; z-index: 0;}
97.57% {top: -325px; opacity: 0; z-index: -1;}
100% {top: -325px; opacity: 0; z-index: -1;}
}
#slider .tooltip{
background: rgba(0,0,0,0.7);
width: 60%;
height; 60px;
position: relative;
bottom: 85px;
}
#slider .tooltip h1{
color: #fff;
font-size: 24px;
font-weight: 300;
line-height: 60px;
padding: 0 0 0 10px;
}
#slider .tooltip {
transition: all 0.3 ease-in-out;
}
#media screen and (max-height: 380px){
#slider{
height: 200px;
}
#mask{
height:190px;
}
#slider img{
height:190px;
}
#slider li{
height:190px;
}
#slider ul{
height:190px;
}
#slider .tooltip{
bottom: 80px;
}
}
Change
#slider img{
max-width:100%;
display:block;
width:100%;
}
Remove absolute values of your image.

CSS bouncing line loader animation

Im trying to create a simple loader animation that draws a line back and forth but currently is moving only in one direction. As soon as it reaches the middle of the animation it does not animate in the oposite direction.
This is my css
#keyframes loader-animation {
0% {
width: 0%;
}
49% {
width: 100%;
}
50% {
left: 100%;
}
100% {
left: 0%;
width: 100%
}
}
.loader {
height: 5px;
width: 100%;
}
.loader .bar {
position: relative;
height: 5px;
background-color: dodgerblue;
animation-name: loader-animation;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
And my html
<div class="loader">
<div class="bar"></div>
</div>
And a jsfiddle with the code
Can someone tell me what I'm doing wrong?
It is because you have a heavy break between 49% and 50%.
49% {
width: 100%;
}
50% {
left: 100%;
}
Adding the left to the 49%, and adjusting a few properties of width, left, etc. gives you an awesome pulsating effect:
#keyframes loader-animation {
0% {
width: 0%;
}
49% {
width: 100%;
left: 0%
}
50% {
left: 100%;
}
100% {
left: 0%;
width: 100%
}
}
Snippet
body {margin: 0; padding: 0;}
#keyframes loader-animation {
0% {
width: 0%;
}
49% {
width: 100%;
left: 0%
}
50% {
left: 100%;
width: 0;
}
100% {
left: 0%;
width: 100%
}
}
.loader {
height: 5px;
width: 100%;
}
.loader .bar {
position: absolute;
height: 5px;
background-color: dodgerblue;
animation-name: loader-animation;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
<div class="loader">
<div class="bar"></div>
</div>
Fiddle: http://jsfiddle.net/praveenscience/06w7zwwm/
If you need a pulsating effect, you need to use two extremes:
#keyframes loader-animation {
0% {
left: -100%;
}
49% {
left: 100%;
}
50% {
left: 100%;
}
100% {
left: -100%;
}
}
Snippet
body {margin: 0; padding: 0; overflow: hidden;}
#keyframes loader-animation {
0% {
left: -100%;
}
49% {
left: 100%;
}
50% {
left: 100%;
}
100% {
left: -100%;
}
}
.loader {
height: 5px;
width: 100%;
}
.loader .bar {
width: 100%;
position: absolute;
height: 5px;
background-color: dodgerblue;
animation-name: loader-animation;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
<div class="loader">
<div class="bar"></div>
</div>
I have slightly changed your code, managed to make it work. Here's what I've changed:
#keyframes loader-animation {
0% {
left: -100%;
}
49% {
left: 100%;
}
50% {
left: 100%;
}
100% {
left: -100%;
}
}
Added overflow: hidden; to .loader
Added width: 100%; to .loader .bar
http://jsfiddle.net/wbyzy9jL/5/

css keyframe left 100% top 100% weird behavior

So basically I am trying to make a box go around the border of the parent with CSS, it works well if I only specify percentage value to either top or left, something like
#keyframes mymove {
0% {top: 0px; left: 0px; background: red;}
25% {top: 0px; left: 100%; background: blue;}
50% {top: 100px; left: 100%; background: yellow;}
75% {top: 100px; left: 0px; background: green;}
100% {top: 0px; left: 0px; background: red;}
}
but it animates very weird if I do
#keyframes mymove {
0% {top: 0px; left: 0px; background: red;}
25% {top: 0px; left: 100%; background: blue;}
50% {top: 100%; left: 100%; background: yellow;}
75% {top: 100%; left: 0px; background: green;}
100% {top: 0px; left: 0px; background: red;}
}
the box got to the far right and then stopped there for 0.5 sec and then back to far right without going to the bottom. And then it jumped to the bottom at left=0px and came back up. You can see the result yourself, kind of hard to explain.
jsfiddler:
http://jsfiddle.net/jzawddLc/
http://jsfiddle.net/jqytraL7/
Running on IE 11 if that is important.
Set 100% height to html, body!
Account a negative margin to the box position
html, body{ height:100%; }
body{margin:0;} /* if needed... */
div {
width: 100px;
height: 100px;
background: red;
position: relative;
-webkit-animation: mymove 5s infinite; /* Chrome, Safari, Opera */
animation: mymove 5s infinite;
}
#keyframes mymove {
0% {top: 0; left: 0; background: red;}
25% {top: 0; left: 100%; margin:0 -100px; background: blue;}
50% {top: 100%; left: 100%; margin:-100px; background: yellow;}
75% {top: 100%; left: 0; margin:-100px 0; background: green;}
100% {top: 0px; left: 0; margin: 0; background: red;}
}
<div></div>
Alternatively, instead of 100% if it's really the window size you're interested in (not an parent-inherited size) you can go for Viewport unit:
#keyframes mymove {
0% {top: 0; left: 0; background: red;}
25% {top: 0; left: calc(100vw - 100px); background: blue;}
50% {top: calc(100vh - 100px); left: calc(100vw - 100px); background: yellow;}
75% {top: calc(100vh - 100px); left: 0; background: green;}
100% {top: 0px; left: 0; background: red;}
}
You need to declare the start position of the box on the element.
//HTML BLOCK
<div id="parent">
<div id="child"></div>
</div>
//CSS BLOCK
#parent{
display: flex;
display: -webkit-flex;
width: 200px;
height: 200px;
background: red;
position: relative;
}
#child{
position: absolute;
width: 100px;
height: 100px;
top: 0%;
left: 0%;
background:blue;
-webkit-animation: mymove 10s infinite;
}
#-webkit-keyframes mymove {
0% {top: 0%; left: 0%; background: red;}
25% {top: 0%; left: 50%; background: blue;}
50% {top: 50%; left: 50%; background: yellow;}
75% {top: 50%; left: 0%; background: green;}
100% {top: 0%; left: 0%; background: orange;}
}

Lag in CSS3 animation

Alright, I am trying to make a pure CSS3 image slideshow. (Yes, I know it could be done with JQuery easier.) I cannot get it to work on my browser, chrome, so I have not yet added the syntax for the other browsers.
My HTML is...
<div class="slide-show">
<img src="pictures/slide-1.jpg" alt="Broken Earth" class="slide-1"/>
<img src="pictures/slide-2.jpg" alt="World Map" class="slide-2"/>
<img src="pictures/slide-3.jpg" alt="Sunset" class="slide-3"/>
<img src="pictures/slide-4.jpg" alt="Ursumian Flag" class="slide-4"/>
</div>
And my CSS is...
.slide-show {
border-style: solid;
border-width: 3px;
border-color: #746d27;
overflow: visible;
width: 600px;
height: 300px;
position: relative;
margin-left: auto;
margin-right: auto;
top: 30px;
}
.slide-1 {
position: relative;
-webkit-animation-name: one;
-webkit-animation-duration: 20s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-play-state: running;
width: 600px;
height: 300px;
}
.slide-2 {
position: relative;
-webkit-animation-name: two;
-webkit-animation-duration: 20s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-play-state: running;
width: 600px;
height: 300px;
}
.slide-3 {
position: relative;
-webkit-animation-name: three;
-webkit-animation-duration: 20s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-play-state: running;
width: 600px;
height: 300px;
}
.slide-4 {
position: relative;
-webkit-animation-name: four;
-webkit-animation-duration: 20s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-play-state: running;
width: 600px;
height: 300px;
}
#-webkit-keyframes one {
0% {left: 0px; top: 0px;}
15% {left: 0px; top: 0px;}
20% {left: 600px; top: 0px;}
21% {left: 600px; top: 300px;}
22% {left: -600px; top: 300px;}
23% {left: -600px; top: 0px;}
95% {left: -600px; top: 0px;}
100% {left: 0px; top: 0px;}
}
#-webkit-keyframes two {
0% {left: -600px; top: -305px;}
15% {left: -600px; top: -305px;}
20% {left: 0px; top: -305px;}
35% {left: 0px; top: -305px;}
40% {left: 600px; top: -305px;}
41% {left: 600px; top: -5px;}
42% {left: -600px; top: -5px;}
43% {left: -600px; top: -305px;}
100% {left: -600px; top: -305px;}
}
#-webkit-keyframes three {
0% {left: -600px; top: -610px;}
35% {left: -600px; top: -610px;}
40% {left: 0px; top: -610px;}
55% {left: 0px; top: -610px;}
60% {left: 600px; top: -610px;}
61% {left: 600px; top: -310px;}
62% {left: -600px; top: -310px;}
63% {left: -600px; top: -610px;}
100% {left: -600px; top: -610px;}
}
#-webkit-keyframes four {
0% {left: -600px; top: -915px;}
55% {left: -600px; top: -915px;}
60% {left: 0px; top: -915px;}
75% {left: 0px; top: -915px;}
80% {left: 600px; top: -915px;}
81% {left: 600px; top: -615px;}
82% {left: -600px; top: -615px;}
83% {left: -600px; top: -915px;}
100% {left: -600px; top: -915px;}
}
Notice, the "slide-show" class does have "overflow" set to "visible." This is so I can make sure all the images are shifting properly. When they do, that will be switched to "hidden." There are 4 pictures, and each should only be moving in/out of the stage for 2 seconds total, and each should spend 3 seconds total sitting in the stage. Why do I have a lag in the last slide?
Don't only use -webkit-, add another one for every 'style' without the -webkit-
Also, can you provide a demo?