本文翻译自:Making a div vertically scrollable using CSS
This 这个
<div id="" style="overflow:scroll; height:400px;">
gives a div
that the user can scroll in both in horizontally and vertically. 给出一个div
,用户可以在水平和垂直方向上滚动。 How do I change it so that the div is only scrollable vertically? 如何更改它以使div 只能垂直滚动?
#1楼
参考:https://stackoom.com/question/ejKv/使用CSS使div可垂直滚动
#2楼
You can use this code instead. 您可以使用此代码。
<div id="" style="overflow-y:scroll; overflow-x:hidden; height:400px;">
overflow-x : The overflow-x property specifies what to do with the left/right edges of the content - if it overflows the element's content area. overflow-x :overflow-x属性指定如何处理内容的左/右边缘 - 如果它溢出元素的内容区域。
overflow-y : The overflow-y property specifies what to do with the top/bottom edges of the content - if it overflows the element's content area. overflow-y