简体   繁体   English

固定div的滚动能力

[英]Scrolling ability in a fixed div

I have a div that slide from the left 100% once you press a button. 按下按钮后,我有一个div从左侧滑动100%。 In that div it will display my menu for the site. 在该div中,它将显示我的网站菜单。 The issue I am having is when on a small browser size the content gets covered and you are unable to see the rest of the links. 我遇到的问题是,当浏览器尺寸较小时,内容会被覆盖,而您看不到其余的链接。

My div #slidingMenu has a fixed positioning and I gave the div an overflow-y:scroll. 我的div #slidingMenu具有固定的位置,我给div设置了溢流y:scroll。 Once I added that code I did have the ability to scroll. 添加该代码后,我确实具有滚动功能。 But the problem was #slidingMenu now slides out displaying a white bar (scrollbar). 但是问题是#slidingMenu现在滑出以显示白色条(滚动条)。 Is there a way to have the main scrollbar of the browser control my menu in #slidingMenu when I scroll? 当我滚动时,是否可以让浏览器的主滚动条控制#slidingMenu中的菜单?

Here is the css and the file http://jsfiddle.net/bC5zh/6/ 这是CSS和文件http://jsfiddle.net/bC5zh/6/

 #footer{
  background-color:#999;
  width:100%;
  height:50px;
  position:absolute;
  top:100%;
  margin-top:-50px;
  line-height:50px;
 }
 #toggle{
  color:#FFF;
  margin-left:50px;
  cursor:pointer;
 }
 #slidingMenu{
  position:fixed;
  background-color:#999;
  width:100%;
  height:100%;
  top:0;
  left:-100%;
  overflow-y:scroll;
 }

You would use 你会用

overflow-y:auto;

To remove the scrollbar but allow for scrolling when inner content is overflowing, updated fiddle 要删除滚动条但允许内部内容溢出时滚动,请更新小提琴

For a smoother scroll on WebKit mobile devices you can use 为了使WebKit移动设备上的滚动更流畅,您可以使用

 -webkit-overflow-scrolling: touch;

Which mimics default iOS scrolling reference 哪个模仿默认的iOS滚动参考

Try adding in your css 尝试添加您的CSS

 #slidingMenu::-webkit-scrollbar { 
   display: none; 
 }

this will hide the scrollbar giving you the ability to still scroll on the site. 这将隐藏滚动条,使您仍然可以在网站上滚动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM