问题
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.
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>
回答1:
Use white-space: nowrap;
on #items
#items{
overflow-x: scroll;
width: auto;
white-space: nowrap;
}
DEMO
回答2:
simply give #items to height and overflow-x:auto.
#items{
overflow-x: auto;
width: auto;
height: 200px;
}
回答3:
<div style="overflow-x:scroll;">
<div style="width:1600px;">
<div style="width:1500px;">
<table>
<tr>
<td> your value <td>
</tr>
</table
</div>
</div>
</div>
来源:https://stackoverflow.com/questions/13379053/how-to-make-horizontal-scroll-on-page