【发布时间】:2020-03-28 14:04:36
【问题描述】:
我想在 jquery mobile 的右侧和左侧有一个菜单。 在这个 (tutorial) 的帮助下,我尝试在左侧制作一个菜单,在右侧制作另一个菜单
我来到了这个结果
$(document).ready(function() {
// only small screens
if ($(window).width() <= 1600) {
// show menu on swipe to right
$(document).on('swiperight', function(e) {
e.preventDefault();
$('#menu').animate({
left: '0'
});
}); // hide menu on swipe to left
$(document).on('swipeleft', function(e) {
e.preventDefault();
$('#menu').animate({
left: '-100%'
});
});
// show menu on swipe to left
$(document).on('swipeleft', function(e) {
e.preventDefault();
$('#menu2').animate({
right: '0'
});
}); // hide menu on swipe to right
$(document).on('swiperight', function(e) {
e.preventDefault();
$('#menu2').animate({
right: '-100%'
});
});
}
});
* {
margin: 0;
padding: 0;
outline: none;
font-family: sans-serif;
}
#menu {
background-color: #E64A4A;
width: 80%;
height: 400px;
position: fixed;
top: 0;
left: -100%;
color: #fff;
}
#menu2 {
background-color: #000;
width: 80%;
height: 400px;
position: fixed;
top: 0;
right: -100%;
color: #fff;
}
h1 {
text-align: center;
margin: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mobile/1.4.5/jquery.mobile.min.js"></script>
<ul id="menu">
<!-- YOUR LINKS GOES HERE -->
</ul>
<ul id="menu2">
<!-- YOUR LINKS GOES HERE -->
</ul>
<h1>Swipe to << or >></h1>
问题是没有菜单就没有中间点 为什么没有菜单就没有中间地带?我哪里出错了?
【问题讨论】:
标签: javascript html jquery css jquery-mobile