html - CSS 正在限制网站的宽度

标签 html css user-interface layout

我正在尝试创建一个干净的跨浏览器管理模板。我编写了一个侧边栏导航,然后是一个主要内容区域。但是我遇到了问题,因为我在主要区域(白色)中的内容似乎并没有一直延伸到整个区域。

代码: http://jsfiddle.net/spadez/Ct5jx/5/

预览: http://jsfiddle.net/spadez/Ct5jx/5/embedded/result/

表格应该占据白色内容区域的整个宽度。如何在不破坏布局的情况下解决这个问题?

这是可能导致问题的代码:

#framecontent {
    position: absolute;
    width: 200px;
    height: 100%;
    overflow: hidden;
    background-color: #34495E;
}
#maincontent {
    position: fixed;
    left: 200px;
    overflow: auto;
}

最佳答案

我不会使用绝对定位和固定定位,而是使用以下设置(应该适用于 ie8 以上的所有浏览器):

html

<div class="wrapper">
    <div class="left">
        left stuff
    </div>
    <div class="right">
        right stuff
    </div>
</div>

CSS

html, body {height: 100%; max-height: 100%; padding:0; margin:0;}
.wrapper {display:table; width:100%; height:100%;}
.wrapper > div {display:table-cell;}
.wrapper .left {width:200px; background-color:#34495E}

Example

您可以将 min-width 添加到 .wrapper 中,这样右列就不会缩小到您想要的尺寸以下

If you need it to work with ie 7, try this

关于html - CSS 正在限制网站的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23131212/

相关文章:

javascript - Phaser 未捕获引用错误 : game is not defined

html - 使一个图像落后于另一个

html - 图片未出现在 <div> 标签中

html - 网页的最佳绝对宽度是多少?

html - 隐藏的输入弄乱了网格

html - CSS、(X)HTML 是严格的还是过渡的以实现跨浏览器兼容性?

html - 多个类选择器不应用属性

java - 使用 editText Activity 更改按钮可见性 onClick

java - for 循环(i) 在循环外使用变量或可能的解决方案?

visual-studio - Visual Studio – 为什么行号默认关闭?