gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 23:48:54 25 4
gpt4 key购买 nike

在移动版本中,向右切换不起作用,它从中心出现。桌面版的完整版没问题。示例: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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com