html - 左列固定宽度,右列高度;右列流体宽度

标签 html css multiple-columns

我正在尝试创建一个两栏网站,左栏的宽度是固定的,但这是我正在努力解决的高度问题。高度应该是窗口的高度或右侧列的高度(以较高者为准)。

在我目前的解决方案中,当右栏比浏览器窗口高并且向下滚动时,左栏会被切掉。

HTML

<div class="side-container">
  <!-- left side -->
  <aside>Left: Fixed width, 100% height of the window or right hand content</aside>
  <!--
  main content -->
  <article>Right: Fluid width</article>
</div>

CSS

.side-container {
  height:100%;
}
.side-container {
  margin: 0;
  padding: 0;
  padding-right: 200px;
  background: rgb(202, 147, 147);
}
aside {
  float: left;
  width: 200px;
  background-color: #e0e0e0;
  height: 100%;
  position: absolute;
  background-color: #e0e0e0;
}
article {
  margin: 0 0 0 200px;
  width: 100%;
  background-color: fuchsia;
  background-color: fuchsia;
}

Fiddle

最佳答案

您真正需要的只是在某些地方使用 min-height 而不是 height:

http://jsfiddle.net/t3AxY/3/

html, body {
    min-height: 100%;
}

.side-container{
    min-height:100%;
    }

.side-container {
    margin: 0;
    padding: 0;
    padding-right: 200px;
    background: rgb(202, 147, 147);
    }

aside{
    float: left;
    width: 200px;
    background-color: #e0e0e0;
    min-height: 100%;
    background-color: #e0e0e0;
    }

article {
    margin: 0 0 0 200px;
    width: 100%;
    background-color: fuchsia;
    }

关于html - 左列固定宽度,右列高度;右列流体宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400140/

相关文章:

javascript - Jquery 动画可排序问题

css - 1px vs 瘦,IE vs Excel 问题

html - 带有 Bootstrap 的 CSS 网格 4 : layout problem when using `col-auto` and `col` with fr unit

来自另一个表的 MySQL JOIN 值基于该表中原始表的(重复)值

html - padding-top&bottom 在我的 css 中来自哪里?

html - 如何使用 CSS 在两个渐变之间创建曲线?

javascript - 如何计算绘制区域的面积?

sql - 使用 SQL Server 2008 R2 查询时如何用另一列替换提取的值

javascript - 我怎样才能强制 PhantomJS 等到 MathJax 完成?

html - CSS Sprite 按钮