2017-01-22 64 views
0

是否可以在css中設置jQuery動畫函數內的回退。 因爲例如calc()在所有瀏覽器中都不起作用。jQuery animate set fallback

CSS:

.element { 
width: 33.33%; 
width: calc(100%/3); 
} 

類似的東西:

$('.element').animate({ 
'width': 33.33%, 
'width': calc(100%/3) 
}); 

謝謝!

+2

你是什麼意思的「回退」? – guest271314

+0

@ guest271314 well calc()在所有瀏覽器中都不起作用 – howtoweb

+0

_「calc()在所有瀏覽器中都不起作用」_ Question中的模式應呈現預期結果。 – guest271314

回答

1

這將是一個更好的選擇添加類的任務,你想

$(document).ready(function(){ 
 

 
     $('.element').addClass('animation'); 
 
     
 
    
 
    })
.element{width:100px;height:100px;background:lightblue} 
 
    .animation{ 
 
    animation-fill-mode:forwards; 
 
    animation:move 2s 1 ease-in-out; 
 
    } 
 
    @keyframes move{ 
 
     0%{width:100%;} 
 
     } 
 
    100%{width:calc(100%/3);}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="element"></div>