Html 如何在页面上进行水平滚动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13379053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make horizontal scroll on page
提问by testCoder
I have div in which placed inner divs i need to make all inner divs in line and horizontal scrollbar should be displayed (i know it sounds crazy, but i need that). I tried container width auto and overflow scroll but nothing.
我有一个 div,其中放置了内部 div,我需要将所有内部 div 排成一行,并且应该显示水平滚动条(我知道这听起来很疯狂,但我需要那个)。我尝试了容器宽度自动和溢出滚动,但没有。
How to accomplish that?
如何做到这一点?
my markup:
我的标记:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>text-overflow</title>
<style>
body{
width: auto;
}
#items{
overflow-x: scroll;
width: auto;
}
.item{
display: inline-block;
width: 400px;
height: 100px;
border:1px solid;
}
</style>
</head>
<body>
<div id="items">
<div class="item">
Item content
</div>
<div class="item">
Item content
</div>
<div class="item">
Item content
</div>
<div class="item">
Item content
</div>
<div class="item">
Item content
</div>
<div class="item">
Item content
</div>
</div>
</body>
</html>
回答by Zoltan Toth
回答by brightboy2004
simply give #items to height and overflow-x:auto.
只需将#items 赋予高度和溢出-x:auto。
#items{
overflow-x: auto;
width: auto;
height: 200px;
}
回答by test
<div style="overflow-x:scroll;">
<div style="width:1600px;">
<div style="width:1500px;">
<table>
<tr>
<td> Your Value </td>
</tr>
</table>
</div>
</div>
</div>