Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css3 background-size transition animation in Webkit doesn't work... Bug? Or wrong syntax? [closed]

Animating the background-size property doesn't seem to be working in Chrome or Safari.

div {      width: 161px;      height: 149px;      background: url(http://3.bp.blogspot.com/_HGPPifzMEZU/Rw4ujF12G3I/AAAAAAAAAWI/bc1ppSb6eKA/s320/estrelas_09.gif) no-repeat center center;      background-size: 50% 50%;      transition: background-size 2s ease-in;      -moz-transition: background-size 2s ease-in;      -web-kit-transition: background-size 2s ease-in  }  div:hover {      background-size: 100% 100%  }
<div>  hey  </div>

http://jsfiddle.net/ubcka/14/

like image 447
HandiworkNYC.com Avatar asked Jan 20 '12 20:01

HandiworkNYC.com


People also ask

Why is animation not working in CSS?

Animation Duration Not Set By default, a CSS animation cycle is zero seconds long. To override this, add an animation-duration rule to your targeted element with a seconds value, in the same block as animation-name. Below, try removing the comments around animation-duration to fix the animation.

Why is transition property not working?

When we want to use transition for display:none to display:block, transition properties do not work. The reason for this is, display:none property is used for removing block and display:block property is used for displaying block. A block cannot be partly displayed. Either it is available or unavailable.

What is CSS WebKit transition?

The -webkit-transition Boolean non-standardCSS media feature is a WebKit extension whose value is true if the browsing context supports CSS transitions. Apple has a description in Safari CSS Reference; this is now called transition there.

How do I use WebKit animation?

To create an animation using WebKit, use the -webkit-animation in conjunction with the @-webkit-keyframes keyword/at-rule, which allows you to define visual effects for your animation. The CSS -webkit-animation property is a proprietary CSS extension that is supported by the WebKit browser engine.


2 Answers

It's not widely supported. See a complete list of CSS properties that support transition here. I would have a different approach. Wrap your element with background-color you wanted to do transition to, and do a scale transition for your element.

<div class="your-wrapper">   <div class="your-div">    </div>    </div> 

also make sure to add proper styling

.your-wrapper {    overflow:hidden } .your-div {    transition: transform 0.5s;     -webkit-transition: -webkit-transform 0.5s } .your-wrapper:hover .your-div{    transform: scale(1.5); -webkit-transform: scale(1.5); } 

This should do.

like image 134
thednp Avatar answered Oct 26 '22 21:10

thednp


You should check the browser version and whether it supports both background-size and transition. If the former, but not the latter use:

transition: background-size 2s ease-in; -moz-transition: background-size 2s ease-in; -ms-transition: background-size 2s ease-in; -o-transition: background-size 2s ease-in; -webkit-transition: background-size 2s ease-in; 
like image 24
Brett Pontarelli Avatar answered Oct 26 '22 23:10

Brett Pontarelli