html - 有一个宽度为 :100% element 的水平滚动条

标签 html css

我的网站中有下一个 DIV(占我页面宽度的 100%):

float: left;
border: solid 2px rgb(119, 36, 98);
width: 100%;
position: relative;
margin-bottom: 10px;
background-color: #eee;
overflow-x: scroll;

enter image description here enter image description here

我想在这个 div 中放置一个比显示的表最大的表(如果需要,还有一个水平滚动条)。

但如果我这样做,则不遵守规则宽度:100%

float: left;
height: 250px;
overflow-y: scroll;
width: 2000px;

enter image description here

有什么想法可以让一个元素在 100% 的屏幕上都有一个水平滚动条吗?

最佳答案

Demo

<div id="scroll">
    <img src="http://thinkingstiff.com/images/priorities.png" />
</div>


html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
}

#scroll {
    height: 100%;
    overflow-x: scroll;    
    white-space: nowrap;
    width: 100%;
}

#scroll img {
    height: 100%;
    vertical-align: top; /* this prevents vertical whitespace */
}

关于html - 有一个宽度为 :100% element 的水平滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23361506/

相关文章:

html - 如何禁用除当前在 angularjs 中选择的所有按钮/图像/div?

javascript - 如何在屏幕上查找 div 元素的 X 和 Y 坐标?

javascript - 为什么我在 div 中的移动按钮没有反应?

html - 在 Grid Bootstrap 中大小相同?

javascript - 在div的左侧添加宽度?

html - 包装调整大小

html - 边框后的额外行

javascript - rc calendar 当我在日历中选择日期时它在文本框中没有改变

jQuery 在单击时循环遍历 sibling 的多个状态

javascript - 单击事件后获取子元素的位置