So if you’re not already familiar, CSS3 transitions do not animate display: none since it removes the targeted element from the DOM altogether. So here’s my issue. I have a sidebar with larger popup divs that appear on hover. Unfortunately Since I can only transition on visibility: hidden and opacity: 0 I have overscroll due to the visibly hidden divs being included in the layout and thus making a very long popup which is accounted for in the page’s scrollbar.
Looking for some creative solutions for how I can still animate without having the scrollbar all screwed up.
I’m developing local so I don’t have a live example to show, but you can see the problem in this screencast: http://dreamstarstudios.com/screencasts/2011-09-27_2111.swf
Thanks in advance!
I’m assuming your popup is absolutely positioned so you could do the following:
topto a huge negative value. This moves it off the screen and gets rid of the scrollbar.topto the correct value and transition theopacityvalue.transitionrules are only for theopacityproperty.HTML
CSS
Here’s the above in action.
Update: To add the left swing, and clean up the mouseout animation, you can use the following code:
It does this as follows:
transition-delayprevents the top value from being changed until the opacity and left animations are complete. The trick here is that when the element is:hover, there is no delay (opacity, left and top animations all start at once). However once:hoveris no longer active, the top animation waits 1 second before starting. This gives opacity and left enough time to finish.Here’s the updated example.