所以这就是我的问题:
结果:
这是代码的摘录。
$('.dropdown-toggle').click(function(){
$('body').toggleClass('menu-dropdown-expanded');
})

body, ul {
margin: 0;
padding: 0;
}
.navbar {
height: 60px;
background: wheat;
}
.dropdown-window {
position: fixed;
top: 60px;
left: 0;
width: 100%;
height: calc(100% - 60px);
background-color: #e7e7e7;
display: none;
-webkit-overflow-scrolling: auto;
overflow-y: scroll;
}
.menu-dropdown-expanded {
overflow-y: hidden;
}
.menu-dropdown-expanded .dropdown-window {
display: block;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="navbar">
<ul class="main-menu">
<li>
<a href="#" class="dropdown-toggle">Dropdown toggle</a>
<div class="dropdown-window">
<ul>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
<li><a href="#">Some item</a></li>
</ul>
</div>
</li>
</ul>
</div>
<div class="my-content">
<p>Lorem ipsum dolor sit amet, vis viris inermis voluptatibus ad, ex ius elitr feugiat. Partem ignota temporibus ea vel, ius mentitum imperdiet in. Ius an clita ancillae placerat, sed graeci adolescens no. Utinam adolescens ullamcorper ea vix. Mel ipsum constituam te. Eu usu hendrerit eloquentiam, te case habeo porro vix.</p>
<p>Mea eu homero munere molestie. Sea facilisi signiferumque ea, mea an labore laboramus liberavisse. Sit ea nemore verear, nec posse populo virtute an. Ne pro nobis impetus. Nec cu vidit rebum augue. Aeque accommodare ne has. Ut vel graece persius bonorum, nam te inimicus persecuti, no pri dicta facilisis philosophia.</p>
<p>Errem accusata recusabo nec ne, at sed causae vivendo, possim detracto expetendis est id. Sit te mutat mazim dolorem, mel ei euripidis neglegentur. Usu eirmod integre minimum et, est mutat docendi delicata in. Qui nihil possit ei, cu nostrud eleifend liberavisse vim.</p>
<p>Ignota apeirian gloriatur at vel. Facete aliquid vulputate te duo, ea viderer placerat nec, est eu alienum posidonium dissentiet. Vis eu brute vocibus ponderum, animal omittantur usu cu. Wisi quas te per. Nec no vidit homero, saperet euripidis duo ut, at meis legendos maluisset per.</p>
<p>Simul iisque elaboraret ut pro. Minim euismod mei ei. Mei dolorem perpetua no. Quo viris admodum at. Ea vim harum apeirian delicata, ut sed interesset necessitatibus, copiosae petentium cu sit.</p>
<p>Nibh corpora invenire ne mea. Mei copiosae constituam te, te ius aeterno legendos pertinax, cu sed fugit hendrerit. Te quodsi comprehensam has, ea vel latine singulis consetetur. Est tation ancillae an, id vim quas vocibus. An mei amet quaeque evertitur, ridens apeirian ad eos. Ut nec minimum pertinax, eu vim veri lorem oportere.</p>
<p>Facer aliquam eos an, pri ex ipsum forensibus. No iusto dicit nam, ridens maluisset usu et. Sed detracto salutandi in, vis ex falli aliquip rationibus. Cu vim eirmod dolorem eligendi. His ea purto graece, feugiat forensibus vituperata ne est. Deleniti vulputate nam id, in labore euripidis omittantur nec.</p>
<p>Duo an regione phaedrum, mazim homero assueverit mel et. Illud adipisci cu his, et error invenire est. Invidunt efficiantur vis no, in vix mollis vocent, vitae debitis in his. Ne aperiri detracto molestie eam, illum euismod nonumes eos ei. Ea unum volutpat mediocritatem mei, eu nam novum oporteat eloquentiam. Quo ad iusto oporteat ocurreret.</p>
<p>Unum labores instructior quo ex, ius te diam viris reprehendunt. Eum debitis vocibus deterruisset eu. Ubique splendide repudiandae ex mea. Ex quo quem omnesque torquatos. Vim ea legere salutatus, at qui dolor sanctus habemus.</p>
<p>Tibique assueverit conclusionemque ut nec, quo illud gubergren ad. Mea commodo invenire ea, ius id oblique virtute constituto, his justo erant vidisse ut. Enim persius quo no, et pro ubique nonumes facilis. Ex vim malis deterruisset, eu diceret honestatis per, mea duis prompta molestiae no. Vim modus lobortis vulputate et, sit posse sententiae honestatis ea, duo cu detraxit reformidans. Et pro summo harum tritani, scripta accusam id mel, nam dicat iudico ex. Choro concludaturque id sed, has suas noster ne, ne aeque quidam mel.</p>
</div>
&#13;
请注意,在codepen上运行代码时无法看到问题。
我确信这可能被标记为重复,但经过一周的研究后,我仍然没有找到任何解决方案。我不是最好的本地js所以我更喜欢使用jQuery。
更新:
截至Hieren feb's answer,我的所有问题都是由iOS的Momentum滚动引起的。当弹出窗口被激活时,将位置:固定到正文固定问题。
答案 0 :(得分:0)
我认为这个问题来自ios的过度滚动,你应该在显示弹出窗口时禁用它。
$( document ).ready(function() {
$('.dropdown-toggle').click(function(){
// Add class to `html` tag instead of `body` tag
$('html').toggleClass('menu-dropdown-expanded');
})
});
&#13;
body, ul {
margin: 0;
padding: 0;
}
.navbar {
height: 60px;
background: wheat;
}
.dropdown-window {
position: fixed;
top: 60px;
left: 0;
width: 100%;
height: calc(100% - 60px);
background-color: #e7e7e7;
display: none;
-webkit-overflow-scrolling: auto;
overflow-y: scroll;
}
/* Prevent overscroll/bounce in iOS MobileSafari by CSS */
.menu-dropdown-expanded,
.menu-dropdown-expanded body {
position: fixed;
overflow: hidden;
}
.menu-dropdown-expanded .dropdown-window {
display: block;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div class="navbar">
<ul class="main-menu">
<li>
<a href="#" class="dropdown-toggle">Dropdown toggle</a>
<div class="dropdown-window">
<ul>
<li class="item1">item 1</li>
<li class="item2">item 2</li>
<li class="item3">item 3</li>
<li class="item4">item 4</li>
<li class="item5">item 5</li>
<li class="item6">item 6</li>
<li class="item7">item 7</li>
<li class="item8">item 8</li>
<li class="item9">item 9</li>
<li class="item10">item 10</li>
<li class="item11">item 11</li>
<li class="item12">item 12</li>
<li class="item13">item 13</li>
<li class="item14">item 14</li>
<li class="item15">item 15</li>
<li class="item16">item 16</li>
<li class="item17">item 17</li>
<li class="item18">item 18</li>
<li class="item19">item 19</li>
<li class="item20">item 20</li>
<li class="item21">item 21</li>
<li class="item22">item 22</li>
<li class="item23">item 23</li>
<li class="item24">item 24</li>
<li class="item25">item 25</li>
<li class="item26">item 26</li>
<li class="item27">item 27</li>
<li class="item28">item 28</li>
<li class="item29">item 29</li>
<li class="item30">item 30</li>
<li class="item31">item 31</li>
<li class="item32">item 32</li>
<li class="item33">item 33</li>
<li class="item34">item 34</li>
<li class="item35">item 35</li>
<li class="item36">item 36</li>
<li class="item37">item 37</li>
<li class="item38">item 38</li>
<li class="item39">item 39</li>
<li class="item40">item 40</li>
<li class="item41">item 41</li>
<li class="item42">item 42</li>
<li class="item43">item 43</li>
<li class="item44">item 44</li>
<li class="item45">item 45</li>
<li class="item46">item 46</li>
<li class="item47">item 47</li>
<li class="item48">item 48</li>
<li class="item49">item 49</li>
<li class="item50">item 50</li>
<li class="item51">item 51</li>
<li class="item52">item 52</li>
<li class="item53">item 53</li>
<li class="item54">item 54</li>
<li class="item55">item 55</li>
<li class="item56">item 56</li>
<li class="item57">item 57</li>
<li class="item58">item 58</li>
<li class="item59">item 59</li>
<li class="item60">item 60</li>
<li class="item61">item 61</li>
<li class="item62">item 62</li>
<li class="item63">item 63</li>
<li class="item64">item 64</li>
<li class="item65">item 65</li>
<li class="item66">item 66</li>
<li class="item67">item 67</li>
<li class="item68">item 68</li>
<li class="item69">item 69</li>
<li class="item70">item 70</li>
<li class="item71">item 71</li>
<li class="item72">item 72</li>
<li class="item73">item 73</li>
<li class="item74">item 74</li>
<li class="item75">item 75</li>
<li class="item76">item 76</li>
<li class="item77">item 77</li>
<li class="item78">item 78</li>
<li class="item79">item 79</li>
<li class="item80">item 80</li>
<li class="item81">item 81</li>
<li class="item82">item 82</li>
<li class="item83">item 83</li>
<li class="item84">item 84</li>
<li class="item85">item 85</li>
<li class="item86">item 86</li>
<li class="item87">item 87</li>
<li class="item88">item 88</li>
<li class="item89">item 89</li>
<li class="item90">item 90</li>
<li class="item91">item 91</li>
<li class="item92">item 92</li>
<li class="item93">item 93</li>
<li class="item94">item 94</li>
<li class="item95">item 95</li>
<li class="item96">item 96</li>
<li class="item97">item 97</li>
<li class="item98">item 98</li>
<li class="item99">item 99</li>
<li class="item100">item 100</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="my-content">
<p>Lorem ipsum dolor sit amet, vis viris inermis voluptatibus ad, ex ius elitr feugiat. Partem ignota temporibus ea vel, ius mentitum imperdiet in. Ius an clita ancillae placerat, sed graeci adolescens no. Utinam adolescens ullamcorper ea vix. Mel ipsum constituam te. Eu usu hendrerit eloquentiam, te case habeo porro vix.</p>
<p>Mea eu homero munere molestie. Sea facilisi signiferumque ea, mea an labore laboramus liberavisse. Sit ea nemore verear, nec posse populo virtute an. Ne pro nobis impetus. Nec cu vidit rebum augue. Aeque accommodare ne has. Ut vel graece persius bonorum, nam te inimicus persecuti, no pri dicta facilisis philosophia.</p>
<p>Errem accusata recusabo nec ne, at sed causae vivendo, possim detracto expetendis est id. Sit te mutat mazim dolorem, mel ei euripidis neglegentur. Usu eirmod integre minimum et, est mutat docendi delicata in. Qui nihil possit ei, cu nostrud eleifend liberavisse vim.</p>
<p>Ignota apeirian gloriatur at vel. Facete aliquid vulputate te duo, ea viderer placerat nec, est eu alienum posidonium dissentiet. Vis eu brute vocibus ponderum, animal omittantur usu cu. Wisi quas te per. Nec no vidit homero, saperet euripidis duo ut, at meis legendos maluisset per.</p>
<p>Simul iisque elaboraret ut pro. Minim euismod mei ei. Mei dolorem perpetua no. Quo viris admodum at. Ea vim harum apeirian delicata, ut sed interesset necessitatibus, copiosae petentium cu sit.</p>
<p>Nibh corpora invenire ne mea. Mei copiosae constituam te, te ius aeterno legendos pertinax, cu sed fugit hendrerit. Te quodsi comprehensam has, ea vel latine singulis consetetur. Est tation ancillae an, id vim quas vocibus. An mei amet quaeque evertitur, ridens apeirian ad eos. Ut nec minimum pertinax, eu vim veri lorem oportere.</p>
<p>Facer aliquam eos an, pri ex ipsum forensibus. No iusto dicit nam, ridens maluisset usu et. Sed detracto salutandi in, vis ex falli aliquip rationibus. Cu vim eirmod dolorem eligendi. His ea purto graece, feugiat forensibus vituperata ne est. Deleniti vulputate nam id, in labore euripidis omittantur nec.</p>
<p>Duo an regione phaedrum, mazim homero assueverit mel et. Illud adipisci cu his, et error invenire est. Invidunt efficiantur vis no, in vix mollis vocent, vitae debitis in his. Ne aperiri detracto molestie eam, illum euismod nonumes eos ei. Ea unum volutpat mediocritatem mei, eu nam novum oporteat eloquentiam. Quo ad iusto oporteat ocurreret.</p>
<p>Unum labores instructior quo ex, ius te diam viris reprehendunt. Eum debitis vocibus deterruisset eu. Ubique splendide repudiandae ex mea. Ex quo quem omnesque torquatos. Vim ea legere salutatus, at qui dolor sanctus habemus.</p>
<p>Tibique assueverit conclusionemque ut nec, quo illud gubergren ad. Mea commodo invenire ea, ius id oblique virtute constituto, his justo erant vidisse ut. Enim persius quo no, et pro ubique nonumes facilis. Ex vim malis deterruisset, eu diceret honestatis per, mea duis prompta molestiae no. Vim modus lobortis vulputate et, sit posse sententiae honestatis ea, duo cu detraxit reformidans. Et pro summo harum tritani, scripta accusam id mel, nam dicat iudico ex. Choro concludaturque id sed, has suas noster ne, ne aeque quidam mel.</p>
</div>
&#13;
这就是我的想法,请检查并让我更新