2012-09-21 36 views

回答

0

您错过了CSS中的一些供应商前缀。

button { 
    width: 100px; 
    -moz-transition: all 1s; 
    -o-transition: all 1s; 
    -webkit-transition: all 1s; 
    transition: all 1s; 
} 

根据这一compat tabletransition s的只有IE10支持,所以我会建议使用jQuery的animate方法,跨浏览器的解决方案:

$('button').click(function() { 
    var toggle = [100, 150], 
     $this = $(this), 
     c = $this.data('count') + 1; 
    $this.data('count', c); 
    $this.stop(true).animate({'width': toggle[c % toggle.length]}, 1000, function() { 
     //done callback 
     count(); 
    }); 
}).data('count', 0); 

Fiddle

取出.stop(true)如果您想排队动画而不是在用户点击动画时点击动画。

+0

Fabicio,看起来像问题是与我正在使用的越野车库:http://www.paulrhayes.com/2011-11/use-css-transitions-to-link-media-queries-and-javascript/。我必须进一步调查。无论如何,感谢您的帮助。 – Behrang

+0

我明白了。没问题。 '=]' –