I am currently writing a HTML5/JS Webapp which will be integrated into pre-existing HTML code. The pre-existing code contains an iframe which then loads the URL of my webapp.
I have the following animation set up in my CSS file:
#-moz-keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
#-webkit-keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
#keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
.container .left .people-container .people .person.slideInLeft {
-webkit-animation: peopleSlideLeft 0.75s forwards;
-moz-animation: peopleSlideLeft 0.75s forwards;
animation: peopleSlideLeft 0.75s forwards;
}
Now if I start my webapp in a window of its own, then the animation plays without issue, however when the webapp is loaded through the iframe, the animation does not fire (Note: This issue only occurs in IE11. Chrome, Firefox and Edge all work correctly both in iframe and out).
The slideInLeft class is definitely attached to the HTML Elements I want to animate, and the #keyframes are definitely in the loaded CSS, but the animation will still not play.
Following images are directly from the IE11 Dev Console:
Is there something I am missing?
Make sure you add non-prefix at the end
#-moz-keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
#-webkit-keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
#-ms-keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
#keyframes peopleSlideLeft {
0% {
left: -500px;
}
100% {
left: 0px;
}
}
.container .left .people-container .people .person.slideInLeft {
-webkit-animation: peopleSlideLeft 0.75s forwards;
-moz-animation: peopleSlideLeft 0.75s forwards;
-ms-animation: peopleSlideLeft 0.75s forwards;
animation: peopleSlideLeft 0.75s forwards;
}
So I have since found out what the issue was. The parent page which contained the iframe that loaded my webapp had the following meta tag in the head section:
<meta http-equiv="X-UA-Compatible" content="IE=9">
Modifying this to be
<meta http-equiv="X-UA-Compatible" content="IE=9;IE=10">
Which allowed the animations to complete successfully.
Related
I am facing a problem with svg on my portfolio page.
I have created svg and I used animation to spin the svg in infinite loop. Problem occures when I reload my portfolio page multiple times. When I do, my screen starts to move towards the center of spinning. I am looking for fix, anyone knows what might help?
images:
after few reloads:
and here is my code:
html {
font-size: 62.5%;
background-color: var(--color-tertiary);
overflow-x: hidden; // My svg is really big and it overflows page, so I need to use this
}
/***************** HEADER **********************/
.header{
width: 100vw;
height: 100vh;
background-position: center;
background-size: cover;
position: relative;
&__logo{ // this is the svg
position: absolute;
top: 0;
left: 30rem;
width: 180rem;
z-index: -1; // I use z-index to make sure that moving svg is in the background of the page
-webkit-animation:spin 4s linear infinite;
-moz-animation:spin 4s linear infinite;
animation:spin 500s linear infinite;
#-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
#-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
#keyframes spin { 100% { -webkit-transform: rotate(360deg);} }
}
&__wrapper{
z-index: 10;
}
}
What I see that this part:
#-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
#-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
#keyframes spin { 100% { -webkit-transform: rotate(360deg);} }
is inside of the class. All keyframes should be standalone. In the #keyframes line also remove -webkit- from transform.
I want an arrow first to fade-in on my site in 1.5 seconds, and after 3 seconds I want it to do a little bounce movement to indicate a scroll movement. I want to repeat the bounce animation every 3rd second but the fade-in only once (when I reload the page).
My code now:
arrow {
position: absolute;
width: 100px;
top: 85vh;
animation: arrowInn 1.5s ease-in forwards, arrowBounce 1s 2s ease-in;
}
#keyframes arrowInn{
from{
opacity: 0;
}
to{
opacity: 100%;
}
}
#keyframes arrowBounce {
0% { bottom: 0px; }
50% { bottom: 10px; }
100% { bottom: 0px; }
}
Your code is already working, you just forgot to add infinite on your second animation:
div {
position: absolute;
width: 100px;
bottom: 10px;
animation: arrowInn 1.5s ease-in forwards, arrowBounce 1s 2s infinite ease-in;
}
#keyframes arrowInn {
from { opacity: 0; }
to { opacity: 100%; }
}
#keyframes arrowBounce {
0% { bottom: 10px; }
50% { bottom: 0; }
100% { bottom: 10px; }
}
<div>⬇️</div>
Also, if you want to make it bounce from the bottom you have to set the bottom property instead of the top on your element. I reversed your arrowBounce animation to make it start from 10px instead of 0, but this part is up to you.
I want to toggle one image with another and vice-versa continuously with some time delay. This is not working in Webkit browsers such as Chrome and Safari.
Here's what I'm doing:
.bkgd_img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.top {
animation-name: toggle;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 5s;
animation-direction: alternate;
}
#keyframes toggle {
0% {
opacity: 1;
}
45% {
opacity: 1;
}
55% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<img class="bottom bkgd_img" src="http://www.placehold.it/500/FF0000" />
<img class="top bkgd_img" src="http://www.placehold.it/500/FF9900" />
The problem that I'm getting is that the "top" image never becomes transparent, the animation does not happen. Where am I going wrong?
Do I need to use browser prefixes for CSS3 Animation in Webkit based browsers?
Yes, the -webkit- prefix is still required currently.
Take a look at this reference here — Currently Chrome, Safari and Opera require the -webkit- prefix in order to support Keyframe Animations.
A note to future readers — This will change in the future as browser vendors adapt the native animation properties. Ensure that the non-prefixed animation property is also used underneath the webkit prefix.
Complete Example
Note: The non prefixed property should be placed underneath the -webkit- prefix. This ensures that supporting browsers will use the native CSS property.
The animation properties have been condensed into one: animation: toggle 5s ease-in-out infinite alternate
.bkgd_img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.top {
-webkit-animation: toggle 5s ease-in-out infinite alternate;
animation: toggle 5s ease-in-out infinite alternate;
}
#-webkit-keyframes toggle {
0% {
opacity: 1;
}
45% {
opacity: 1;
}
55% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes toggle {
0% {
opacity: 1;
}
45% {
opacity: 1;
}
55% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<img class="bottom bkgd_img" src="http://www.placehold.it/500/FF0000" />
<img class="top bkgd_img" src="http://www.placehold.it/500/FFFF00" />
tested your code in Firefox 32 and IE10 and Chrome 36. It seems to work fine with IE and Mozilla. But does not work well with chrome. Chrome has different CSS notations, it is not able to read them, kindly use following code for chrome. You can retain your previous code for other browsers
.top {
-webkit-animation-name:toggle;
animation-name: toggle;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 5s;
-webkit-animation-direction: alternate;
}
#-webkit-keyframes toggle {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}
You missed vendor specific css property.
-webkit-animation: toggle 5s infinite;
#-webkit-keyframes toggle {}
Refer the working code.
http://codepen.io/bhuvana/pen/dPYzdZ
If you want to use JQuery with a simple way of doing this. There are other ways of doing it example: toggle()
HTML:
<img class="bottom bkgd_img" src="xyz.jpg" id="img-change" />
JQuery:
$('#img-change').on({
'click': function () {
var originalsrc = $(this).attr('src');
var src = '';
if (originalsrc == 'xyz.jpg') src = 'abc.jpg';
if (originalsrc == 'abc.jpg') src = 'xyz.jpg';
$(this).attr('src', src);
}
});
Note: I didn't try it, but it probably works.
You have to use vendor specific code, you can check it in below code
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
.bkgd_img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.top {
-webkit-animation: 5s 'toggle' infinite alternate;
-moz-animation: 5s 'toggle' infinite alternate;
-o-animation: 5s 'toggle' infinite alternate;
animation: 5s 'toggle' infinite alternate;
}
#keyframes 'toggle' {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}#-webkit-keyframes 'toggle' {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}#-moz-keyframes 'toggle' {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}#-o-keyframes 'toggle' {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}
</style>
</head>
<body>
<img class="bottom bkgd_img" src="xyz.jpg" />
<img class="top bkgd_img" src="abc.jpg" />
</body>
</html>
I use CSS Animation and media queires like this!
HTML
<div class='block'>
<div class='block-bar'></div>
</div>
CSS
.block-bar {
-webkit-animation: timebar 1s infinite;
-moz-animation: timebar 1s infinite;
animation: timebar 1s infinite;
}
#keyframes timebar {
0% { width: 0%; }
99% { width: 100%; }
100% { width: 0%; }
}
#-webkit-keyframes timebar {
0% { width: 0%; }
99% { width: 100%; }
100% { width: 0; }
}
}
it work correctly in Chrome and Firefox but not working in IE
How to fix it? Thank you.
The problem is that IE doesn't like it when keyframes are defined within mediaqueries. If you pull the definition for the keyframes outside the mediaquery it works. (Tested in IE11)
#keyframes timebar {
0% { width: 0%; }
99% { width: 100%; }
100% { width: 0%; }
}
#media(min-width: 300px){
.block-bar {
height: 50px; background-color: red;
-webkit-animation: timebar 1s infinite;
-moz-animation: timebar 1s infinite;
animation: timebar 1s infinite;
}
#-webkit-keyframes timebar {
0% { width: 0%; }
99% { width: 100%; }
100% { width: 0; }
}
}
I'm running into a problem. I'd simply like to, once one CSS3 animation has completed, have my next animation begin (ideally a fade in)
Here's the first animation code:
#truck {
position: absolute;
margin-top:90px;
-moz-animation: slide 4s;
-webkit-animation: slide 4s;
-ms-animation: slide 4s;
animation: slide 4s;
animation-fill-mode: forwards;
-webkit-animation-fill-mode: forwards;
}
#keyframes slide {
0% { left: 0px; }
35% { left: 250px; }
65% { left: 250px; }
100% { left:590px; }
}
#-webkit-keyframes slide {
0% { left: 0px; }
35% { left: 250px; }
65% { left: 250px; }
100% { left:590px; }
}
#-ms-keyframes slide {
0% { left: 0px; }
35% { left: 250px; }
65% { left: 250px; }
100% { left:590px; }
}
If anyone can help me with the second animation and how to call that once the first one is completed, I would greatly appreciate it.
I think you can use delay:
animation-delay:4s;
-moz-animation-delay:4s; /* Firefox */
-webkit-animation-delay:4s; /* Safari and Chrome */
-o-animation-delay:4s; /* Opera */
(adjust number to fit)