Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动画方法不接受带有“calc”的宽度值_Javascript_Jquery_Css_Css Animations - Fatal编程技术网

Javascript 动画方法不接受带有“calc”的宽度值

Javascript 动画方法不接受带有“calc”的宽度值,javascript,jquery,css,css-animations,Javascript,Jquery,Css,Css Animations,当您点击隐藏菜单按钮绿色线条时,侧菜单隐藏和后包裹必须将宽度更改为全尺寸-但这不会发生 我试图通过变量设置宽度值-结果,它可以工作,但没有动画 $(document).ready(function(){ // HIDE-MENU BUTTON TOGGLE: full width of post wrap $('#hide-menu-btn').toggle(function(){ var x = $('.post-wrap').css('width','calc(100%

当您点击隐藏菜单按钮绿色线条时,侧菜单隐藏和后包裹必须将宽度更改为全尺寸-但这不会发生

我试图通过变量设置宽度值-结果,它可以工作,但没有动画

$(document).ready(function(){
  // HIDE-MENU BUTTON TOGGLE: full width of post wrap
  $('#hide-menu-btn').toggle(function(){
      var x = $('.post-wrap').css('width','calc(100% - 15px)');
      $('.post-wrap').animate({width:x},200);
    },function(){
      var y = $('.post-wrap').css('width','calc(100% - 135px)');
      $('.post-wrap').animate({width:y},200);
  });  
});
如何使用动画方法设置包裹后宽度的动画