我正在使用js菜单构建网站,该菜单将内容加载到容器div中。该网站在台式机以及台式机浏览器上的响应式移动仿真器上均能正常运行,但在手机上无法滚动。
https://clippingpointmedia.co.za/cpm2019dev/
这是我的主要样式表:
/* CSS Document */
body {
padding: 0;
margin: 0;
background-color: #222;
font-family: 'Comfortaa';
}
#container {
display: block;
padding: 0;
}
#content {
margin-top: 0;
margin-right: 70px;
margin-left: 70px;
margin-bottom: 0px;
max-height:100vh;
overflow:hidden;
transition-timing-function: ease-in-out;
transition-duration: 0.5s;
}
#page-content {
width: 100%;
min-height: 100vh;
}
#loader {
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #2693C1;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#mobile-nav, .mobile-footer {
display: none;
}
.side-nav {
position: fixed;
top: 50%;
transform: translateY(-50%);
left: -300px;
width: 360px;
transition-timing-function: ease-in-out;
transition-duration: 0.5s;
}
.side-menu {
width: 300px;
background-color: #fff;
}
.menu-toggle, .mobile-menu-toggle {
width: 60px;
height: 60px;
background-size: 90%;
background-image: url("../images/MenuButtonOpen.svg");
background-position: center;
background-repeat: no-repeat;
cursor: pointer;
float: right;
position: relative;
transition-delay: 0.1s;
transition-timing-function: ease-in-out;
transition-duration: 0.4s;
}
.menu-top {
height: 150px;
padding: 20px 0 0;
text-align: center;
}
#mobile-cp-logo {
background: url("../images/HomeIcon-light.svg") no-repeat center;
height: 45px;
padding-top: 10px;
margin-bottom: 10px;
margin-left: -30px
}
#cp-logo {
height: 120px;
max-width: 175px;
display: block;
margin: 0 auto 20px;
background: url("../images/HomeIcon-dark.svg") no-repeat center;
transition-delay: 0.1s;
transition-timing-function: ease-in-out;
transition-duration: 0.4s;
}
#pt-container {
padding: 15px 0;
background-color: #ccc;
text-align: center;
transition-delay: 0.1s;
transition-timing-function: ease-in-out;
transition-duration: 0.4s;
width: 100%;
}
#prod-title, #digi-title, #event-title {
background-color: #ccc;
text-transform: uppercase;
color: #fff;
border-top: 1px solid #2693C1;
border-bottom: 1px solid #2693C1;
padding: 10px 0;
width: 66.66667%;
margin: 0 auto;
font-size: 20px;
font-weight: 300;
display: none;
}
.side-menu ul {
list-style: none;
}
.side-ul ul {
list-style: none;
margin: 0;
padding: 0;
}
.side-ul li a {
display: block;
color: #fff;
text-align: center;
width: 100%;
padding: 30px 0;
background: linear-gradient(#444 0%, #1c1c1c 100%);
font-weight: 700;
font-size: 18px;
text-transform: lowercase;
text-decoration: none;
}
.side-ul li a::after, .top-ul li a::after {
float: right;
content: url("../images/arrow-right.svg");
padding-right: 20px;
padding-left: -20px;
}
.side-ul li a:focus::before, .top-ul li a:focus::before {
float: left;
content: url("../images/arrow-left.svg");
padding-right: -20px;
padding-left: 20px;
}
.side-sub-ul ul, .side-footer ul, .mobile-sub-ul ul {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
}
.side-sub-ul li, .side-footer li, .mobile-sub-ul li {
float: left;
width: 33.333333%;
}
.side-sub-ul li a, .side-footer li a, .mobile-sub-ul li a {
display: block;
text-align: center;
text-transform: lowercase;
text-decoration: none;
width: 100%;
}
.side-sub-ul li a, .mobile-sub-ul li a {
color: #606060;
background-color: #ccc;
font-size: 13px;
padding: 18px 0;
margin: 7px 0;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
.side-sub-ul li, .mobile-sub-ul li {
background-color: #ccc;
list-style-type: none;
}
.side-footer li a {
color: #273658;
font-size: 8px;
padding: 5px 0;
background-color: #fff;
width: 100%;
}
.show {
display: initial
}
.hide {
display: none;
}
.menu-item-tablet {
display: none !important;
}
.wes-hi {
border-top: 1px solid #fff !important;
border-bottom: 1px solid #fff !important;
}
.social {
position: fixed;
width: 60px;
top: 50%;
right: 0;
transform: translateY(-50%);
}
.social a {
display: block;
text-align: center;
padding: 9px 0;
}
.mobile-footer a {
color: #fff;
font-size: 8px;
text-decoration: none;
padding: 0 5px;
}
.mobile-footer li {
display: inline-block;
}
#totop-btn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
border: none;
outline: none;
background-color: rgba(0,0,0,0.8);
color: white;
cursor: pointer;
padding: 1px 14px 7px 15px;
font-size: 30px;
border-radius: 0;
transform: rotate(-90deg);
}
#totop-btn:hover {
color: #2693C1;
}
#bg {
position: fixed;
top: 0;
min-height: 100vh;
min-width: 100vw;
overflow: hidden;
z-index: -9;
background: url("../images/full-bg.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
/* Responsive Queries */
@media only screen and (max-width: 992px) {
/* Tablet View */
.menu-item {
display: none !important;
}
.menu-item-tablet {
display: block !important;
}
#content {
margin-right: 0;
/* padding-top: 10px;/* height: calc(100vh - 10px);*/
}
.social {
width: 100%;
bottom: 0;
transform: none;
text-align: center;
background: rgba(0,0,0,0.8);
top: auto;
position:absolute;
}
.social a {
display: inline-block;
padding: 5px;
}
.social a img {
transform: scale(0.75);
}
.mobile-footer {
display: inline-block;
vertical-align: 95%;
}
#totop-btn {
bottom: 50px;
}
.side-footer {
display: none
}
}
@media only screen and (max-width: 359px), (orientation: landscape) and (max-width:600px) {
/* Small Mobile View */
#container {
display: block;
width: 100%;
min-height: -webkit-fill-available;
}
#content {
margin-left: 0;
margin-top: 0;
padding-top: 0;
}
#page-content {
min-height: calc(100vh - 138px);
overflow: scroll;
-webkit-overflow-scrolling: touch;
}
.side-nav {
display: none;
position:absolute;
visibility: hidden;
z-index: -99999;
}
#mobile-nav {
/* position: fixed;*/
top: 0;
width: 100%;
display: block;
background-color: rgba(0,0,0,0.8);
padding: 10px 0;
height: 55px;
overflow: hidden;
transition-timing-function: ease-in-out;
transition-duration: 0.5s;
}
.mobile-menu-toggle {
height: 55px;
}
.top-ul li a {
display: block;
color: #fff;
text-align: center;
width: 100%;
padding: 20px 0;
background: linear-gradient(#444 0%, #1c1c1c 100%);
font-weight: 700;
font-size: 14px;
text-transform: lowercase;
text-decoration: none;
}
.mobile-footer {
/* vertical-align: top;*/
padding-bottom: 3px;
}
.social {
height: 63px;
}
.social a {
padding: 4px 10px 0;
}
.side-sub-ul li a, .mobile-sub-ul li a {
padding: 15px 0;
margin: 7px 0;
}
}
以及相关的html:
<body>
<div id="loader"></div>
<div id="container" style="display: none">
<div id="mobile-nav">
<div class="mobile-menu-toggle" onclick="togglemobilenav()"></div>
<ul class="top-ul">
<div id="mobile-cp-logo"></div>
<li><a href="#" class="menu-item-tablet" onclick="togglemobilenav(); load_production()">Production</a>
</li>
<li><a href="#" class="menu-item-tablet" onclick="togglemobilenav(); load_digital()">Digital</a>
</li>
<li><a href="#" class="menu-item-tablet" onclick="togglemobilenav(); load_events()">Events</a>
</li>
</ul>
<ul class="mobile-sub-ul">
<li><a href="#" class="menu-item-tablet" onclick="togglemobilenav(); load_about()">About</a>
</li>
<li><a href="#" class="menu-item-tablet wes-hi" onclick="togglemobilenav(); load_news()">News</a>
</li>
<li><a href="#" class="menu-item-tablet" onclick="togglemobilenav(); load_contact()">Contact</a>
</li>
</ul>
</div>
<div class="side-nav">
<div class="menu-toggle" onclick="togglenav()"></div>
<div class="side-menu">
<div class="menu-top">
<div id="cp-logo"></div>
<div id="pt-container" style="display:none">
<div id="prod-title">Production</div>
<div id="digi-title">Digital</div>
<div id="event-title">Events</div>
</div>
</div>
<ul class="side-ul">
<li><a href="#production" class="menu-item" onclick="load_production()">Production</a>
</li>
<li><a href="#production" class="menu-item-tablet" onclick="togglenav(); load_production()">Production</a>
</li>
<li><a href="#digital" class="menu-item" onclick="load_digital()">Digital</a>
</li>
<li><a href="#digital" class="menu-item-tablet" onclick="togglenav(); load_digital()">Digital</a>
</li>
<li><a href="#events" class="menu-item" onclick="load_events()">Events</a>
</li>
<li><a href="#events" class="menu-item-tablet" onclick="togglenav(); load_events()">Events</a>
</li>
</ul>
<ul class="side-sub-ul">
<li><a href="#about" class="menu-item" onclick="load_about()">About</a>
</li>
<li><a href="#about" class="menu-item-tablet" onclick="togglenav(); load_about()">About</a>
</li>
<li><a href="#news" class="menu-item wes-hi" onclick="load_news()">News</a>
</li>
<li><a href="#news" class="menu-item-tablet wes-hi" onclick="togglenav(); load_news()">News</a>
</li>
<li><a href="#contact" class="menu-item" onclick="load_contact()">Contact</a>
</li>
<li><a href="#contact" class="menu-item-tablet" onclick="togglenav(); load_contact()">Contact</a>
</li>
</ul>
<ul class="side-footer">
<li><a href="#">© clipping point 2019</a>
</li>
<li><a href="#terms" class="menu-item" onclick="load_terms()">our terms & conditions</a>
</li>
<li><a href="#terms" class="menu-item-tablet" onclick="togglenav(); load_terms()">our terms</a>
</li>
<li><a href="#privacy" class="menu-item" onclick="load_privacy()">our privacy policy</a>
</li>
<li><a href="#privacy" class="menu-item-tablet" onclick="togglenav(); load_privacy()">our privacy policy</a>
</li>
</ul>
</div>
</div>
<!-- content will be loaded here -->
<div id="content"></div>
<div class="social">
<a href="https://www.linkedin.com/company/clipping-point-media/" class="linkedin" target="_blank"><img src="images/li-icon.svg" alt="" /></a>
<!-- <a href="https://www.facebook.com/clippingpointza/" class="facebook" target="_blank"><img src="images/fb-icon.svg" alt="" /></a>-->
<a href="https://twitter.com/clippingpointza" class="twitter" target="_blank"><img src="images/tw-icon.svg" alt="" /></a>
<a href="https://www.youtube.com/channel/UCHAc4aC70UAr4Qa_GFFNDUQ" class="youtube" target="_blank"><img src="images/yt-icon.svg" alt="" /></a>
<a href="https://www.instagram.com/clippingpointmedia_/" class="instagram" target="_blank"><img src="images/insta-icon.svg" alt="" /></a>
<ul class="mobile-footer">
<li><a href="#">© clipping point 2019</a>
</li>
<li><a href="#terms" class="menu-item-tablet" onclick="closemobilenav(); load_terms()">our terms</a>
</li>
<li><a href="#privacy" class="menu-item-tablet" onclick="closemobilenav(); load_privacy()">our privacy policy</a>
</li>
</ul>
</div>
</div>
<div id="bg"></div>
</body>
我认为这与#page-content div的高度有关,我将其设置为min-height:calc(100vh-138px)以补偿顶部的导航栏和底部的页脚。
或者,它可能与可见性或其他元素的位置有关。网站的布局在较小的设备上会完全改变...
我尝试添加-webkit-overflow-scrolling:touch;到各种元素,但是即使使用* {}将其设置为所有元素,它仍然不会滚动。
我已经阅读了十几篇文章,其中一些文章指出了位置:已修复,因此我尝试切换到绝对位置...
似乎整个页面都在尝试滚动而不是#content或#page-content div ...我只是茫然不知所措!请帮助!!!
答案 0 :(得分:0)
在@media only screen and (max-width: 800px)
的{{1}}的{{1}}内的CSS下方添加第style.css
行。这将无法使您的父级滚动和禁用单个容器的滚动,并且您还会在每个容器中添加单个页脚。因此,我还隐藏了所有容器的页脚,并且仅可见最后一个容器的页脚。试试这个,希望对您有所帮助。谢谢
4030