Pure CSS scroll animation

Use anchor links and the scroll-behavior property (MDN reference) for the scrolling container: scroll-behavior: smooth; Browser support: Firefox 36+, Chrome 61+ (therefore also Edge 79+), Safari 15.4+, Opera 48+. Intenet Explorer, non-Chromium Edge and older versions of Safari (that are still used by some users) do not support scroll-behavior and simply “jump” to the link … Read more

Why does enabling hardware-acceleration in CSS3 slow down performance?

I always add : -webkit-backface-visibility: hidden; -webkit-perspective: 1000; When working with 3d transform. Even “fake” 3D transforms. Experience tells me that these two lines always improve performances, especially on iPad but also on Chrome. I did test on your exemple and, as far as I can tell, it works. As for the “why” part of … Read more

Animate an element’s width from 0 to 100%, with it and it’s wrapper being only as wide as they need to be, without a pre-set width, in CSS3 or jQuery

I think I’ve got it. .wrapper { background:#DDD; display:inline-block; padding: 10px; height: 20px; width:auto; } .label { display: inline-block; width: 1em; } .contents, .contents .inner { display:inline-block; } .contents { white-space:nowrap; margin-left: -1em; padding-left: 1em; } .contents .inner { background:#c3c; width:0%; overflow:hidden; -webkit-transition: width 1s ease-in-out; -moz-transition: width 1s ease-in-out; -o-transition: width 1s ease-in-out; transition: … Read more

CSS how to make an element fade in and then fade out?

Use css @keyframes .elementToFadeInAndOut { opacity: 1; animation: fade 2s linear; } @keyframes fade { 0%,100% { opacity: 0 } 50% { opacity: 1 } } here is a DEMO .elementToFadeInAndOut { width:200px; height: 200px; background: red; -webkit-animation: fadeinout 4s linear forwards; animation: fadeinout 4s linear forwards; } @-webkit-keyframes fadeinout { 0%,100% { opacity: 0; … Read more

Can CSS3 transition font size?

The color transitions fine over time, but the font switches immediately for some dagnabbit reason. Your font-size transition is being overwritten by your color transition. transition: font-size 12s; /* transition is set to ‘font-size 12s’ */ transition: color 12s; /* transition is set to ‘color 12s’ !! */ Instead, you must combine them all into … Read more

How do I normalize the CSS3 transition end events across browsers?

There’s a technique used in Modernizr, improved: function transitionEndEventName () { var i, undefined, el = document.createElement(‘div’), transitions = { ‘transition’:’transitionend’, ‘OTransition’:’otransitionend’, // oTransitionEnd in very old Opera ‘MozTransition’:’transitionend’, ‘WebkitTransition’:’webkitTransitionEnd’ }; for (i in transitions) { if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) { return transitions[i]; } } //TODO: throw ‘TransitionEnd event is not supported in … Read more

CSS3 Transitions: Is “transition: all” slower than “transition: x”?

Yes, using transition: all could cause major drawbacks in performance. There can be a lot of cases where the browser would look if it needs to make a transition, even if user won’t see it, like the color changes, dimension changes etc. The simplest example I can think of is this: http://dabblet.com/gist/1657661 — try to … Read more