html - CSS 3 列流体布局问题,第 3 列太宽

标签 html css

我一直在尝试通过遵循 http://www.alistapart.com/articles/holygrail/ 来实现 3 列流体布局(左侧 300px 固定,中心流体,右侧 300px 固定)并且出于某种原因,第 3 列超出了布局的右侧。

这是我想要的与我得到的:http://i.stack.imgur.com/qFVVP.png

我正在 Linux Chrome 和 FF 上测试它——这两个都是最新的稳定版本。

我的 CSS 是:

#home {
    min-width:900px;
    font-family: arial;
    font-size: 12px;
    color: #565656;
}

/* Main Page Divisions */

#page-top {
    height: 120px;
    background-color: #ffffffff;
}

#page-middle {
    height: 250px;
    background-color: #6AC0EB;
    float:left;
    width:100%;
    padding-left: 300px;   /* LC width */
    padding-right: 300px;  /* RC width */
}

#page-middle .column {
  position: relative;
  float: left;
}

#page-bottom {
    clear:both;
    height: 300px;
    background-color:#EDEDED;
    overflow:scroll;
}

/* Middle Page Divisions */

#page-middle-centre {
    width:60%;
}

#page-middle-left {
    width: 300px;          /* LC width */
    right: 300px;          /* LC width */
    margin-left: -60%;
}
#page-middle-right {
    width: 300px;          /* RC width */
    margin-right:-300px;  /* RC width */
    background: #FDE95E;
}

/* Bottom Page Divisions */

#page-bottom-left {
    width: 49%; 
    float:left;
    text-align: right;
}

#page-bottom-right {
    width: 49%; 
    float:right;
    text-align: left;
}

h2 {
    font-family: "Quicksand";
    font-size: 130%;
}

h1#title-block {
    font-family: "Quicksand";
    font-size: 3em;
    color: #FFFFFF;
    letter-spacing:-3px;
}

而我的 HTML 如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Test Layout</title>
    <link rel="stylesheet" type="text/css" href="reset.css" />  
    <link rel="stylesheet" type="text/css" href="test.css" />
    <!--[if IE]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>

<body id="home">


    <div id="page-top">
    This is the header  
  </div>


    <div id="page-middle">

    <div id="page-middle-centre" class="column">
        middle section middle section middle section middle section middle section middle section middle section middle section  
    </div>      

    <div id="page-middle-left" class="column">
          <h1 id="title-block">Title Block</h1>
          <p id="quicksand">Menu 1 | Menu 2 | Menu 3 | Menu 4</p>
    </div>

    <div id="page-middle-right" class="column">
      Right section Right section Right section Right section Right section Right section Right section Right section 
    </div>  
  </div>

    <div id="page-bottom">
    This is the footer
  </div>
</body>
</html>

最佳答案

在您的 html 中,您的列 div 的顺序为:

  1. 左栏
  2. 居中栏
  3. 右栏

您在 alistapart 网站上使用的示例的列顺序为:

  1. 居中栏
  2. 左栏
  3. 右栏

将它们调换一下,它可能会正常工作。 祝你好运!

关于html - CSS 3 列流体布局问题,第 3 列太宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5130904/

相关文章:

php - 我正在尝试在 php 中运行邮件表单。这是带有 Bootstrap 3.0 的 HTML

c++ - 如何在 QTextDocument 中使用表格的框架属性,即使它不受支持?

javascript - 过渡持续时间不适用于 VanillaJS

php - 如何在 HTML 中显示 SQL TABLE 单击下拉列表

javascript - 停止垂直线滚动

html - :last-child in ng-repeat not working

javascript - 如何将选中的项目保留在列表顶部

html - 当顶部 div 可以改变高度时,如何垂直堆叠两个 div(并在另一个 div 内)?

html - 如何在 &lt;input type ="text"> 中显示多个图像

javascript - Bootstrap 导航栏占用了两行