javascript - Toggle.slide.right 不能在移动设备上正常工作

标签 javascript jquery html css

在移动版本中,向右切换不起作用,它从中心出现。桌面版的完整版没问题。 示例:https://streamable.com/eiy8c

$("#buttonStart").click(function() {
  {
    $('#content101').toggle('slide', {
      direction: 'right'
    }, 500);
  }
});

$("#buttonClose").click(function() {
  {
    $('#content101').toggle('slide', {
      direction: 'right'
    }, 500);
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="buttonStart">
<input id="buttonClose">
<div id="content101">
  Content
</div>

我试过向左切换,没问题。

最佳答案

use animate() function instead.

<!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
    <script> 
    $(document).ready(function(){
      $("button").click(function(){
        $("div").animate({left: '250px'});
      });
    });
    </script> 
    </head>
    <body>

    <button>Start Animation</button>

    <p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>

    <div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>

    </body>
    </html>

关于javascript - Toggle.slide.right 不能在移动设备上正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56647826/

相关文章:

jquery - 使div向下滑动而不向下推内容

jquery - 自动调整容器中的图像

html - CSS:使文本在图像宽度处中断

javascript - 如何在 Node.js 中更改或编辑 Html

javascript - 使用 jQuery 对数组中的元素进行动画处理

javascript - 在 Google Maps API 中获取标记的坐标

javascript - 如何在一个同步块(synchronized block)中异步执行多个ajax调用(jquery)

javascript - 向函数添加多个语句

html - 如何调整 html 邮件程序中的图像大小以支持智能手机和 pc?

javascript - AngularJs。是否可以通过单击取消选择 HTML “radio” 输入?