2012-09-21 34 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

我明白了。沒問題。 '=]' –