css - 溢出:滚动 - 侧滚动关闭页面

标签 css overflow

设置了一个带有 overflow: scroll 的 div,但尽管我将 div 的宽度设置为 100%,但我的内容超出了页面的一侧。

#main {
     background: #ccc;
     height: 100%;
     overflow: auto;
     margin-top: -8px;
     z-index: 1000;
     padding-top: 4px;
     float: right;
     width: 100%;
     min-height: 100%;
 }

 #main #chat {
     padding-top: -1px;
     padding-left: 0px;
     margin-left: 210px;
     height: 100%;
     width: auto;
     float: right;
     min-height: 100%;
 }

我该如何排序?

此处示例:www.dellserve.co.uk/private

最佳答案

您已为 body 设置了 100% 的宽度,因此它将拉伸(stretch) 100% 的屏幕,不包括填充和边距。您的浏览器为 body 提供了默认边距:

enter image description here

(我在chrome中是8px)所以你body的宽度是100%+left margin+right margin,当然是100%以上;

给你的 body 一个零边际,你会很好:

body{
    min-width: 100%;
    height: auto;
    font-family: Tahoma, Helvetica;
    margin: 0;
}

关于css - 溢出:滚动 - 侧滚动关闭页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19542081/

相关文章:

html - 子元素水平溢出时,为什么忽略了父元素的右填充?

css - 完美的圆形边框

html - 向导航栏添加多个背景图像/颜色

html - 为所有浏览器和 Windows/OSX 设置 <select> <option> 下拉框的样式 css

css - 在 SharePoint Designer 中添加新的 Css 样式

html - 如何使内容在 CSS 网格布局中居中?

html - 看不到第三个分区。溢出另一个

iframe - 删除垂直滚动条,将水平滚动条保留在Chrome的iframe中

css - 左侧固定宽度div,右侧填充剩余宽度div

css - 位置固定的父子,父溢出 :hidden bug