CSS transition shorthand with multiple properties?

Syntax: transition: <property> || <duration> || <timing-function> || <delay> [, …]; Note that the duration must come before the delay, if the latter is specified. Individual transitions combined in shorthand declarations: -webkit-transition: height 0.3s ease-out, opacity 0.3s ease 0.5s; -moz-transition: height 0.3s ease-out, opacity 0.3s ease 0.5s; -o-transition: height 0.3s ease-out, opacity 0.3s ease 0.5s; … Read more

How can I transition width of content with width: auto?

As I commented, one can’t animate auto (yet), so either use the max-width/max-height trick, or, if you need it to be more exact, set the width using a script. With the max-width/max-height trick, give it a value big enough to accommodate the widest. Stack snippet .myspan { display: inline-block; font-size: 30px; background-color: #ddd; vertical-align: bottom; … Read more

Transition background-color via slide animation

In order to slide the background color up you would need to use a background image, or a gradient of some sort, while gradually adjusting the background-position: .box { width: 200px; height: 100px; background-size: 100% 200%; background-image: linear-gradient(to bottom, red 50%, black 50%); -webkit-transition: background-position 1s; -moz-transition: background-position 1s; transition: background-position 1s; } .box:hover { … Read more

CSS Animation and Display None

CSS (or jQuery, for that matter) can’t animate between display: none; and display: block;. Worse yet: it can’t animate between height: 0 and height: auto. So you need to hard code the height (if you can’t hard code the values then you need to use javascript, but this is an entirely different question); #main-image{ height: … Read more

Callback on CSS transition

Yes, if such things are supported by the browser, then an event is triggered when the transition completes. The actual event however, differs between browsers: Webkit browsers (Chrome, Safari) use webkitTransitionEnd Firefox uses transitionend IE9+ uses msTransitionEnd Opera uses oTransitionEnd However you should be aware that webkitTransitionEnd doesn’t always fire! This has caught me out … Read more