同一页面中的响应和无响应代码

时间:2015-03-31 23:59:05

标签: html5 css3 twitter-bootstrap responsive-design

我正在处理的网站非常庞大,我们无法立刻对整个网站进行枪击。所以,我们必须分阶段建设。问题是,我们将从90年代的表结构网站转到Bootstrap-divs响应式网站。这意味着,一旦我们构建并发布第一阶段,它必须在整个站点中保持一致。

换句话说,页眉/页脚必须在非响应页面(使用表构建)和响应页面(引导程序)等方面工作并且看起来相同。因此,由于该网站将成为一个完整的响应式网站,因此标题会响应,但不是网站的其他部分。

这是我的问题,我的标题固定在顶部,它是响应式的。页面内容没有使用响应代码,所以我在底部(当然)得到一个滚动条。但是,除非我修复它并且我不能这样做,否则页脚拒绝100%宽度。它必须保持在底部,它必须也是响应。

我用简单的香草页面制作了一个代码表来显示我的问题。见here

页脚类

footer{
   width:100%;
   background:#ddd;
   height:35px;
}

现在,出于某种原因,实际上确实将页脚保持在底部(或者看起来如此)但是如果我添加position:absolute和bottom:0,它实际上会移动到页面的中心而不是!

1 个答案:

答案 0 :(得分:1)

那是一个令人讨厌的人。

您可以将非响应式页面内容包装在另一个元素中,以防止它导致<body>级别的水平滚动条。然后,仅允许该元素水平滚动。

这不是理想的,但它会一直有效,直到你可以使整个网站始终如一地响应。

.page-content-wrap {
  max-width: 100%;
  overflow-x: scroll;
}
.page-content {
  padding-top: 70px;
  width: 1170px;
  margin: 0 auto;
}
footer {
  width: 100%;
  background: #ddd;
  height: 35px;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />

<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Project name</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a>
        </li>
        <li><a href="#about">About</a>
        </li>
        <li><a href="#contact">Contact</a>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Action</a>
            </li>
            <li><a href="#">Another action</a>
            </li>
            <li><a href="#">Something else here</a>
            </li>
            <li class="divider"></li>
            <li class="dropdown-header">Nav header</li>
            <li><a href="#">Separated link</a>
            </li>
            <li><a href="#">One more separated link</a>
            </li>
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="../navbar/">Default</a>
        </li>
        <li><a href="../navbar-static-top/">Static top</a>
        </li>
        <li class="active"><a href="./">Fixed top <span class="sr-only">(current)</span></a>
        </li>
      </ul>
    </div>
    <!--/.nav-collapse -->
  </div>
</nav>

<div class="page-content-wrap">
  <div class="page-content">
    <div class="box">
      <h1>Navbar example</h1>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
      <p>To see the difference between static and fixed top navbars, just scroll.</p>
      <p>
        <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs »</a>
      </p>
    </div>

  </div>
  <!-- /container -->
</div>

<footer>
  <div class="container">
    Footer
  </div>
</footer>