Sil*_*ght 6 css jquery jquery-animate
请参阅下面的jQuery:
我真的不知道我该如何使用CSS !important为height在此代码.
$j('#lveis-wrapper_3').animate({
opacity: 0.0,
height : 200
}, 1200);
Run Code Online (Sandbox Code Playgroud)
CSS #lveis-wrapper_3如下:
#lveis-wrapper_3
{
width: 844px !important;
height: 936px !important;
margin: 0pt 0pt 10px !important;
padding: 0pt !important;
float: none;
}
Run Code Online (Sandbox Code Playgroud)
我无法!important从height: 936px某些原因中删除...
所以我想height通过animate()jQuery函数改变它- 但是如何?
你不能这样做.
根据jQuery文档 ...
"所有动画属性都应该动画为单个数值 ... ...大多数非数字属性无法使用基本的jQuery功能进行动画处理......"
http://api.jquery.com/animate/
我强烈建议您重新检查一下您的需求!important.
小智 6
您可以使用 css 过渡来使其工作,因为即使通过 $(elem).attr('style', '...'); 更改了 style 属性,CSS 过渡也会工作。
你用:
// the element you want to animate
$(elem).attr('style', 'your_style_with_important');
Run Code Online (Sandbox Code Playgroud)
elem {
transition: all 0.2 linear;
-moz-transition: all 0.2 linear;
-webkit-transition: all 0.2 linear;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8373 次 |
| 最近记录: |