如何在页面上进行水平滚动 [英] How to make horizontal scroll on page
本文介绍了如何在页面上进行水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个div,其中放置了内部div,我需要使所有内部div对齐,并显示水平滚动条(我知道这听起来很疯狂,但我需要这样做)。我尝试了容器宽度自动和溢出滚动,但是什么也没做。
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.
如何实现?
我的标记:
<!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>
推荐答案
使用空格: nowrap;
在 #items
#items{
overflow-x: scroll;
width: auto;
white-space: nowrap;
}
这篇关于如何在页面上进行水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文