html - 将屏幕分成 1 顶行和 2 列。两列应该是浏览器的 100% 高度

标签 html css

这是我的问题的 fiddle 链接:http://jsfiddle.net/YZrae/2/

请注意如何在左侧出现一个额外的滚动条。我需要删除这个额外的滚动条,但无法弄清楚我做错了什么......

我需要左右两列来保留它们的滚动条,但删除出现的其余部分。

这是我在 fiddle 中使用的代码:

HTML:

<div class="top_wrap"></div>
<div class="content_wrap">
  <div class="col_right_wrap"></div>
  <div class="col_left_wrap"></div>
  <div class="clear"></div>
</div>

CSS:

html,body {
padding:0;
margin:0;
height:100%;
min-height:100%;
}
.top_wrap{
background-color:red;
height:50px;
}
.content_wrap{
background-color:blue;
height:100%;
position:relative;
}
.col_right_wrap{
float:right;
height:100%;
background-color:green;
width:50%;
overflow-y: scroll;
}
.col_left_wrap{
float:left;
width:49%;
height:100%;
background-color:yellow;
overflow-y: scroll;
}
div.clear { clear: both; height: 1px; overflow: hidden; font-size:0pt; margin-top: -1px; }

有什么建议吗?谢谢!

最佳答案

如果您对一些 jQuery 没问题,那么这个就可以了。

这是一个jsFiddle .

代码 jQuery 代码将 .content-wrap 调整为(窗口高度 - .top_wrap 高度)。这是 jQuery 代码:

<script>
functionHeight = function () {
    var varBrowserHeight = $(window).height();
    var varTopWrapHeight = $(".top_wrap").height();

    $(".content_wrap").css('height', (varBrowserHeight - varTopWrapHeight));
};

$(document).ready(function () {
    functionHeight();
});

$(window).resize(function (event) {
    functionHeight();
});
</script>

关于html - 将屏幕分成 1 顶行和 2 列。两列应该是浏览器的 100% 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15463214/

相关文章:

css - 是否可以将文本对齐与 Braintree Hosted Forms 一起使用?

javascript - 使用 CSS 谷歌可视化的 slider 颜色配置

jQuery'悬停导致div闪烁

iPhone 5 屏幕尺寸 VS CSS 媒体查询

html - 如何使用 CSS 对齐内容后面的子菜单?

javascript - 在 AngularJS 框架范围内的页面加载时调用 Web 服务

javascript - 当我更改下拉列表中的状态时,它会更改 Angular js中实际范围的值

css - JavaFX - 用于定义 StageStyle 的 css 文件位于何处或如何更改它?

css - 使用 css 从 ms word 重新创建 smartart 人字形列表

html - Div 不能像 inline-block 一样正确