2014-11-05 80 views

回答

1

的问题是,因为#box元素不被你的榜样滚动 - 的window是。默认情况下,块元素将展开以适应其内容。为了制止这种行为,并允许元素滚动您需要设置其heightoverflow属性:

#box { 
    height: 100px; /* amend this as required */ 
    overflow: scroll; 
} 

Updated fiddle

1

你应该高度和overflow属性添加到您的div来使“滚动”事件工作。

#box { 
    overflow: auto; 
    height: 200px; 
} 

JSFiddle example

相关问题