2013-08-28 37 views
0

我有一个元素,我使用jquery添加了类,以便为背景属性设置动画/执行CSS转换。我的目标是在运动过程中暂停过渡,我想也许我可以通过获取元素的当前背景属性,然后将css设置为获得的属性来完成此操作。在css转换过程中获取元素的背景属性JQUERY

HTML

<div id="productimage">  
    </div> 

CSS

#productimage { 
    -webkit-transition: all 2.5s ease-out; -moz-transition: all 2.5s ease-out; -o-transition: all 2.5s ease-out; 

} 

#productimage.step2 { 
    background-size:1500px 2275px; 
    background-position: 30% 30%; 
} 

#productimage.step3 { 
    background-image: url("../img/blusen-back.jpg"); 
    background-size:396px 600px; 
    -webkit-transition: all 2.5s ease-out; -moz-transition: all 2.5s ease-out; -o-transition: all 2.5s ease-out; 
} 

回答

0
$(function() { 
    $('#giveMetheCurrentStyle').click(function() { 
     var obj, matrix; 
     obj = document.getElementById('circle'); 
     matrix = getComputedStyle(obj).getPropertyValue('transform'); 
     console.log(matrix); 
     //$("#myDiv").css('transform', matrix) 

     }); 
}); 

在这里阅读更多http://dev.opera.com/articles/view/understanding-3d-transforms/

+0

确保它工作使用供应商前缀http://leaverou.github.io/prefixfree/ –