Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 避免在导航和站点中进行双滚动_Css - Fatal编程技术网

Css 避免在导航和站点中进行双滚动

Css 避免在导航和站点中进行双滚动,css,Css,我让我的网站的一部分-div侧边栏,导航和全屏。但现在我可以在这个div中滚动一次,我有第二个(主)滚动的网站 我想删除其中一个滚动条,当显示时,访问者只能在导航div中滚动 边栏div现在有了这个css .sidebar { display: none; position: fixed; top: 70px; width: 100%; height: 100%; overflow: auto; z-index: 2; background: #FFFFFF; } 你可以在这里看到page l

我让我的网站的一部分-div侧边栏,导航和全屏。但现在我可以在这个div中滚动一次,我有第二个(主)滚动的网站

我想删除其中一个滚动条,当显示时,访问者只能在导航div中滚动

边栏div现在有了这个css

.sidebar {
display: none;
position: fixed;
top: 70px;
width: 100%;
height: 100%;
overflow: auto;
z-index: 2;
background: #FFFFFF;
}
你可以在这里看到page live

我的错在哪里?我希望最终结果是这样的


谢谢

以下是jquery的解决方案:

//if your side bar is visible
if($('.sidebar').is(':visible')){
$('html').css('overflow','hidden');//add css to html or body element to hide the outer scroll
}

您可以使用jquery进行此操作吗?您已将导航格式化为
位置:fixed
overflow:auto
,因此当导航内容高于可用空间时,此行为是意料之中的。感谢Nishanth,第一个切换侧边栏非常适合使用。隐藏侧边栏时,主要内容的滚动消失。可能需要添加“else”代码吗?我通过添加:else{$('html').css('overflow','visible');}来修复它