CSS Keyframe Animation Not Working in Chrome - css

I've got an css keyframe animation set on a background div with a lot of going on—3d transformations, opacity, color, etc. The animation worked perfectly fine in Chrome a couple months ago, but doesn't seem to work now. It still works great in Safari.
Essential code related to the problem below; full code/live site here; *note that the transformation is overtaking by mouse movement as well(this works fine in Chrome + Safari).
Sry, please don't hate me for my poop and sexytime naming conventions ;)
HTML
<div class="background-container" id="poop">
<div class="background-movement">
</div>
</div>
<script>
var element = document.getElementById('poop');
document.addEventListener('mousemove', function (e) {
var transform = 'rotateX('+e.pageY*.05+'deg) rotateY('+e.pageX*.02+'deg)';
element.style.webkitTransform = transform;
element.style.transform = transform;
}, false);
</script>
CSS
.background-container {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
}
.background-movement {
background-image: url(../img/bg.png);
z-index: 100;
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background-repeat: repeat;
background-size: 500px;
-webkit-animation: sexytime 60s ease-in-out 0 infinite alternate;
animation: sexytime 60s ease-in-out 0 infinite alternate;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
#-webkit-keyframes sexytime {
0% {
opacity: 1;
-webkit-filter: hue-rotate(0deg) brightness(.8);
-webkit-transform-origin: left;
-webkit-transform:scale(1) rotate3d(10, 0, 0, 20deg);
}
20%{
-webkit-transform:scale(1.3) rotate3d(20, 30, -10, 40deg);
}
40% {
opacity: .9;
-webkit-filter: hue-rotate(60deg) brightness(1);
}
50% {
opacity: .8;
-webkit-filter: hue-rotate(300deg) brightness(1.3);
-webkit-transform-origin: top;
-webkit-transform:scale(1.3) rotate3d(70, 10, 30, -10deg);
}
60% {
opacity: 1;
-webkit-transform:scale(1.3) rotate3d(10, -40, 0, 30deg);
}
80% {
opacity: .9;
-webkit-filter: hue-rotate(-30deg) brightness(1.3);
-webkit-transform:scale(1.3) rotate3d(20, 30, -20, 30deg);
}
100% {
opacity: 1;
-webkit-filter:hue-rotate(120deg) brightness(1);
-webkit-transform-origin: bottom;
-webkit-transform:scale(.9) rotate3d(30, -10, 50, 20deg);
}
}
#keyframes sexytime {
0% {
opacity: 1;
filter: hue-rotate(0deg) brightness(.8);
transform-origin: left;
transform:scale(1) rotate3d(10, 0, 0, 20deg);
}
20%{
transform:scale(1.3) rotate3d(20, 30, -10, 40deg);
}
40% {
opacity: .9;
filter: hue-rotate(60deg) brightness(1);
}
50% {
opacity: .8;
filter: hue-rotate(300deg) brightness(1.3);
transform-origin: top;
transform:scale(1.3) rotate3d(70, 10, 30, -10deg);
}
60% {
opacity: 1;
transform:scale(1.3) rotate3d(10, -40, 0, 30deg);
}
80% {
opacity: .9;
filter: hue-rotate(-30deg) brightness(1.3);
transform:scale(1.3) rotate3d(20, 30, -20, 30deg);
}
100% {
opacity: 1;
filter:hue-rotate(120deg) brightness(1);
transform-origin: bottom;
transform:scale(.9) rotate3d(30, -10, 50, 20deg);
}
}

Related

CSS: Perspective Hover Effect on Section

Trying to get a hover effect to work hovering over a section (with no link). I've seen it used elsewhere but can't seem to get it right on my version.
To view what I'm trying to do, go to http://wpstaging.centerstaging.com/studios/studio-1/#specifications and attempt to hover over the first section which says 'Power'.
CSS:
.specs {
transition: 0.4s ease;
}
.specs:before {
height: 100%;
opacity: 0;
z-index: -1;
bottom: 0;
left: 0;
content: '';
transform: perspective(1000px) rotateX(90deg);
transform-origin: 50% 100%;
transition: all 0.4s cubic-bezier(0.2, 0, 0.15, 1);
background-image: linear-gradient(-264deg, #52227f -50%, #ff004e 100%);
}
.specs:hover:before {
opacity: 1;
transform: perspective(1000px) rotateX(0);
}
HTML (edited):
<section class="elementor-section elementor-inner-section specs">
</section>
Instead of standard selectors like class and id what you can use here is the attribute selectors. The "Power" Section in your code have a data-id attribute
which can be given styles like below.
[data-id^="44962df"]:hover {
background-image: linear-gradient(254deg, #52227F 50%, #FF004E 100%);
}
Resulting to this on hover
Solved it. Took some experimentation, but here's what worked.
.specs:after {
background-image: linear-gradient(-264deg, #52227f -50%, #ff004e 100%)!important;
content: "";
height: 100%;
left: 0;
top: 0;
width: 100%;
position: absolute;
transform: perspective(1000px) rotateX(90deg);
transform-origin: 50% 100%;
transition: all 0.4s cubic-bezier(0.2, 0, 0.15, 1);
z-index: -1;
}
.specs:hover:after{
opacity: 1;
transform: perspective(1000px) rotateX(0);
}

I'm trying to correct the animation duration and timeline of infinite flip, rotation, spin and disappearance of three images in pure CSS

I tested with the following answers:
Pure CSS rotate animation broken while in infinite loop
Stop infinite CSS3 animation and smoothly revert to initial state
CSS Image Fade Animation Only Runs First Time,
but the animation duration and timeline (for example, from step by step, from start to end) did not work. The three images need to be in the same place at once.
I wanted to use https://codepen.io/jay-bee-why/pen/Htejl, but unfortunately I do not want to use jQuery. I am CSS and JavaScript purist.
An image is worth a thousand words. You will understand easily the image. I also provide very small snippet code box.
.flipping-images
{
align-items: center;
display: flex;
flex-flow: row nowrap;
height: 80%;
justify-content: center;
/* opacity: 0; */
position: relative;
transform: translateX(100%);
width: 22%;
}
.show-l
{
animation: show-image 5s ease-in-out 300ms infinite;
left: 0;
position: absolute;
transform-origin: left;
}
.hide-l
{
animation: hide-image 5s ease-in-out 800ms infinite;
position: absolute;
transform-origin: left;
}
.hide-l2
{
animation: hide-image 5s ease-in-out 600ms infinite;
position: absolute;
transform-origin: right;
}
#keyframes hide-image
{
0%
{
left: 0;
transform: rotateY(0deg);
}
30%
{
left: 10%;
transform: rotateY(0deg);
}
50%
{
opacity: 1;
}
100%
{
left: -100%;
opacity: 0;
transform: rotateY(90deg);
}
}
#keyframes show-image
{
0%
{
left: 100%;
transform: rotateY(90deg);
}
30%
{
left: 110%;
transform: rotateY(90deg);
}
100%
{
left: 0%;
transform: rotateY(0deg);
}
}
<div class="flipping-images">
<img class="show-l" src="https://via.placeholder.com/432x864/fdc34f/FEFEFE?text=1">
<img class="hide-l2" src="https://via.placeholder.com/432x864/3e72ff/FEFEFE?text=2">
<img class="hide-l" src="https://via.placeholder.com/432x864/222222/FEFEFE?text=3">
</div>
I'm not sure I understand your image since it says the second image should disappear but it also says the animation is infinite. I hope it's working as you intended, if not just leave a comment on what needs to be fixed.
I'm using the animationend event to control the animations.
var counter = 1;
var div = document.querySelector('.flipping-images');
var images = document.querySelectorAll('.flipping-images img');
var showNext = function () {
counter++;
if (counter > 3) counter = 1;
div.classList.remove('image1', 'image2', 'image3')
div.classList.add('image'+counter);
};
for (var img of images) {
img.addEventListener('animationend', showNext);
img.addEventListener('click', showNext);
}
document.querySelector('#next').addEventListener('click', showNext);
.flipping-images {
perspective: 300px;
}
.flipping-images img {
display: none;
animation: rotate 5s linear 1;
}
.flipping-images.image1 img:nth-child(1),
.flipping-images.image2 img:nth-child(2),
.flipping-images.image3 img:nth-child(3) {
display: block;
}
.flipping-images.image2 img:nth-child(2) {
animation: rotate 5s linear infinite;
}
#keyframes rotate {
0% { transform: rotateY(-45deg); }
100% { transform: rotateY(45deg); }
}
button {
margin: 1em;
}
<div class="flipping-images image1">
<img src="https://via.placeholder.com/100x100/fdc34f/FEFEFE?text=1">
<img src="https://via.placeholder.com/100x100/3e72ff/FEFEFE?text=2">
<img src="https://via.placeholder.com/100x100/222222/FEFEFE?text=3">
</div>
<button id="next">Next</button>

How can I give this blob svg a scroll morph effect?

I currently have a blob in the background of my website and I'd like to morph it and make it interactive as the user scrolls down the page, what can I add to do this? ATM, the blob is animated but not on scroll.
Here is the html
<div class="morph-wrap">
<svg class="morph" width="1400" height="770" viewBox="0 0 1400 770">
<path
d="M 262.9,252.2 C 210.1,338.2 212.6,487.6 288.8,553.9 372.2,626.5 511.2,517.8 620.3,536.3 750.6,558.4 860.3,723 987.3,686.5 1089,657.3 1168,534.7 1173,429.2 1178,313.7 1096,189.1 995.1,130.7 852.1,47.07 658.8,78.95 498.1,119.2 410.7,141.1 322.6,154.8 262.9,252.2 Z" />
</svg>
</div>
Here is the css
/* SVG Morph */
.morph-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 100%;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
}
.morph {
position: relative;
height: 100%;
fill: rgb(33, 33, 33);
flex: none;
animation: animate 5s linear infinite;
}
#keyframes animate {
0% {
transform: scale(1) translate(10px, -30px);
}
38% {
transform: scale(0.8, 1) translate(80vw, 30vh) rotate(160deg);
}
40% {
transform: scale(0.8, 1) translate(80vw, 30vh) rotate(160deg);
}
78% {
transform: scale(1.3) translate(0vw, 50vh) rotate(-20deg);
}
80% {
transform: scale(1.3) translate(0vw, 50vh) rotate(-20deg);
}
100% {
transform: scale(1) translate(10px, -30px);
}
}

CSS animation in MS Edge and IE animates in wrong direction

I have created a simple css animation that translates an pseudo element vertically. This animation works great in Chrome, FireFox and Safari but not so much in Microsoft Edge or Internet Explorer.
I am struggling to figure out the reason for this bug. Any help would be great!
How the animation should look:
How it looks in Edge and IE:
Animation example: https://jsfiddle.net/9x5vckhb/
#keyframes scroll {
0% {
transform: translate(-50%, 20%);
opacity: 0;
},
30% {
opacity: 1;
},
40% {
opacity: 1;
},
70% {
transform: translate(-50%, 120%);
opacity: 0;
},
100% {
transform: translate(-50%, 120%);
opacity: 0;
}
}
I am wondering if this is a bug or not. I for the life could not wrap my head around this. It seemed like the x & y were being swapped after the first animation loop. Switched to transform3d() and it worked perfectly.
Fiddle
&:before {
content: '•';
font-size: round($width/100*63.3);
top: 0;
transform: translate3d(-50%, 30%, 0);
animation: scroll ease 3s;
animation-iteration-count: infinite;
}
And
#keyframes scroll {
0% {
transform: translate3d(-50%, 20%, 0);
opacity: 0;
},
30% {
opacity: 1;
},
40% {
opacity: 1;
},
70% {
transform: translate3d(-50%, 120%, 0);
opacity: 0;
},
100% {
transform: translate3d(-50%, 120%, 0);
opacity: 0;
}
}

Element placed with CSS :after selector starts out hidden in CSS3 animation

I have a CSS3 animation of a Christmas label on a string that drops down from the top of the browser window, pauses, and then retracts. The label's string is currently a separate image that is added to the label image via the :after CSS selector.
Here is an example on Codepen http://codepen.io/KurtWM/full/KAxpk that is set up to run over and over for troubleshooting purposes.
Nine times out of ten, the very first time the animation runs, the string image is hidden. It is not missing, it just does not show up. But then if you do something to the window, like re-size it, or right click and select "Inspect Element" (if you are running Developer Tools) the string will suddenly appear:
Here is the initial run of the page with the string hidden:
And here the string appears when the window is re-sized:
I cannot figure out why the string will not show up initially. Sometimes it will suddenly show up after a delay, but usually you have to "tweak" the browser in some way to get it to show up.
I will probably end up having to manually add a string image, but I am really puzzled as to why this is happening. Any solutions will be appreciated.
Simplified Code (some animation steps removed and using only -webkit- properties):
/* ************************************* */
/* Animations
/* ************************************* */
#-webkit-keyframes fade-out {
0% {
opacity: 0;
filter: alpha(Opacity=0);
}
40% {
opacity: 0;
filter: alpha(Opacity=0);
}
55% {
opacity: 1;
filter: alpha(Opacity=100);
}
100% {
opacity: 1;
filter: alpha(Opacity=100);
}
}
#-webkit-keyframes swing {
0% {
-webkit-transform: rotate(0);
-webkit-transform: translate(0, -460px);
}
16% {
-webkit-transform: translate(0, 0);
}
92% {
-webkit-transform: translate(0, 0);
}
100% {
-webkit-transform: rotate(0);
-webkit-transform: translate(0, -460px);
}
}
/* ************************************* */
/* Element styles */
/* ************************************* */
#stage {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.swing:after {
position: absolute;
top: -110px;
left: 46%;
z-index: 20;
content: url(http://www.johnsonferry.org/portals/0/assets/newsevents/images/CP-string.png);
-webkit-filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
filter: url(#drop-shadow);
-ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=2, OffY=2, Color='rgba(0, 0, 0, 0.5)')";
filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=2, OffY=2, Color='rgba(0, 0, 0, 0.5)')";
}
.swing:before {
position: absolute;
top: 0px;
left: 0px;
z-index: 10;
content: url(http://www.johnsonferry.org/portals/0/assets/newsevents/images/CP-gift-label-back.png);
-webkit-animation: fade-out 8.5s ease 5s infinite normal;
}
.swing {
position: absolute;
top: 100px;
left: 50%;
width: 250px;
margin-left: -125px;
-webkit-transform: translate(0, -460px);
/* animate the swing with pendulum-style easing */
-webkit-animation: swing 8.5s ease-in-out 5s infinite normal;
animation: swing 8.5s ease-in-out 5s infinite normal;
-webkit-transform-origin: 46% -110px 0;
-webkit-transform-style: preserve-3d;
}
.shadowed {
-webkit-filter: drop-shadow(6px 9px 4px rgba(0, 0, 0, 0.5));
filter: url(#drop-shadow);
-ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=6, OffY=9, Color='rgba(0, 0, 0, 0.5)')";
filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=6, OffY=9, Color='rgba(0, 0, 0, 0.5)')";
}
I think that I have isolated the problem to a bug related to the animation, the pseudo element and the filter.
I have it working with this CSS (changing a property by an animation). I am showing only the changes !
.swing:after {
-webkit-animation: shadow 0.5s infinite;
/*
-webkit-filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
*/
}
#-webkit-keyframes shadow {
0% { -webkit-filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));}
100% { -webkit-filter: drop-shadow(2px 2px 4px rgba(0, 0, 1, 0.5));}
}
Notice that the animation is pretty much a fake (I mean, it doesn't animate much), but looks like it's working. I guess that it makes Chrome recalculate the filter, that somehow was at the root of the problem.

Resources