粘性页脚,但只是有时......续

发布于 2024-09-07 05:12:37 字数 6625 浏览 12 评论 0原文

好吧,现在出现了新的问题。我最初遇到的问题是:粘性页脚,但只是有时。我的浏览器中有一个滚动条,但我似乎无法消除额外的 70 像素边距...

<div id="wrapper">
<div id="headwrapper">
<div id="header"></div>
    <div id="menu">
       <ul>
          <li class="active"><a href="#" title="Link1">Link1</a></li>
          <li><a href="#" title="Link2">Link2</a></li>
          <li><a href="#" title="Link3">Link3</a></li>
          <li><a href="#" title="Link4">Link4</a></li>
          <li><a href="#" title="Link5">Link5</a></li>
       </ul>        
    </div>
    <div id="content-container">
          <div id="content">
              <h2>
                  Page heading
              </h2>
              <p>
                  Lorem ipsum dolor sit amet consect etuer adipi scing elit sed diam nonummy nibh euismod tinunt ut laoreet dolore magna aliquam erat volut. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
              </p>
              <p>
                  Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
              </p>
              <p>
                  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
              </p>
          </div>
          <div id="aside">
              <h3>
                  Aside heading
              </h3>
              <div class="box">
              <p>
                  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan.
              </p>
              </div>
              <div class="box">
              <p>
                  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan.
              </p>
              </div>
          </div>
 </div>
</div>
</div>
<div id="footer">
 <p>Footer content</p>
</div>

样式表:

* {margin:0}

html, body {height:100%;}

#wrapper {
    max-width:100%;
    min-width:1000px;
    min-height:100%;
    margin:0 auto;
    background-image:url(images/shadowborder.png);
    background-repeat:repeat-y;
    background-position:center;
    padding-bottom:70px;
    overflow:auto;
}

#headwrapper {
    position:relative;
    -moz-background-clip:border;
    -moz-background-origin:padding;
    -moz-background-size:auto auto;
    background-color:#003a72;
    background:url(images/bnr_rpt.jpg) repeat-x;
    height:150px;
}

#header {
    position:relative;
    -moz-background-clip:border;
    -moz-background-origin:padding;
    -moz-background-size:auto auto;
    background-color:transparent;
    background:url(images/KMIAFS_banner.jpg) center top no-repeat;
    height:150px;
}

#menu {
    clear:left;
    float:left;
    padding:0;
    border-top:5px solid #f52620;
    width:100%;
    overflow:hidden;
    height:70px;
}


#menu ul {
    float:left;
    margin:0;
    padding:0;
    list-style:none;
    position:relative;
    left:50%;
    text-align:center;
}

#menu ul li {
    display:block;
    float:left;
    list-style:none;
    margin:0;
    padding:0;
    position:relative;
    right:50%;
    font-size:16px;
    font-family:Verdana, Geneva, sans-serif!important;
    font-weight:bold;
}

#menu ul li a {
    display:block;
    float:left;
    margin:0 2px 0 0;
    padding:10px 20px 6px 20px;
    background:#003a72;
    text-decoration:none;
    color:#FFF;
}

#menu ul li a:hover {
    padding:15px 20px 6px 20px;
    background-color:#999;
}

#menu ul li.active a, #menu ul li.active a:hover {
     color:#CCC;
}

#content-container {
    min-height:100%;
    height:100%;
    margin:0 auto;
    width:1000px;
}

#content {
    clear:left;
    float:left;
    width:610px;
    padding:10px;
    margin:0 0 0 30px;
    display:inline;
    background-color:transparent;
}

#content img {
    border:solid 2px #CCC;
    float:left;
    margin:14px 10px 10px 0px;
}

#content h2 {
    margin-bottom:10px;
}

#aside {
    float:right;
    width:290px;
    margin:0 40px 0 0px;
    display:inline;
    background-color:transparent;
}

#aside p {
    color:#CCC;
}

#aside h3 {
    padding-bottom:20px;
}

#aside .box {
    margin-bottom:20px;
    padding:20px;
    color:#fff;
    background-color:#336699;
    -webkit-border-radius:20px;
    -moz-border-radius:20px;
}

#footer {
    position:relative;
    height:70px;
    width:100%;
    border-top:5px solid #f52620;
    background:url(images/ftr_rpt.jpg) repeat-x;
    text-align:center;
    color:#FFF;
    margin:0 auto;
    margin-top:-70px;
    clear:both;
}

#footer a {
    color:#FFF;
    text-decoration:none!important;
    padding:-5px;
}

#footer a:hover {
    color:#CCC;
}

那么我在这里缺少什么? 这是网站:http://www.erisdesigns.net/Stage/McCampbellInsurance/index。 html

OK, so now there's a new wrinkle. The original problem I was having: Sticky Footer, but only sometimes. I have a scroll bar in my browser, and I can't seem to make the extra 70px margin go away...

<div id="wrapper">
<div id="headwrapper">
<div id="header"></div>
    <div id="menu">
       <ul>
          <li class="active"><a href="#" title="Link1">Link1</a></li>
          <li><a href="#" title="Link2">Link2</a></li>
          <li><a href="#" title="Link3">Link3</a></li>
          <li><a href="#" title="Link4">Link4</a></li>
          <li><a href="#" title="Link5">Link5</a></li>
       </ul>        
    </div>
    <div id="content-container">
          <div id="content">
              <h2>
                  Page heading
              </h2>
              <p>
                  Lorem ipsum dolor sit amet consect etuer adipi scing elit sed diam nonummy nibh euismod tinunt ut laoreet dolore magna aliquam erat volut. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
              </p>
              <p>
                  Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
              </p>
              <p>
                  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
              </p>
          </div>
          <div id="aside">
              <h3>
                  Aside heading
              </h3>
              <div class="box">
              <p>
                  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan.
              </p>
              </div>
              <div class="box">
              <p>
                  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan.
              </p>
              </div>
          </div>
 </div>
</div>
</div>
<div id="footer">
 <p>Footer content</p>
</div>

stylesheet:

* {margin:0}

html, body {height:100%;}

#wrapper {
    max-width:100%;
    min-width:1000px;
    min-height:100%;
    margin:0 auto;
    background-image:url(images/shadowborder.png);
    background-repeat:repeat-y;
    background-position:center;
    padding-bottom:70px;
    overflow:auto;
}

#headwrapper {
    position:relative;
    -moz-background-clip:border;
    -moz-background-origin:padding;
    -moz-background-size:auto auto;
    background-color:#003a72;
    background:url(images/bnr_rpt.jpg) repeat-x;
    height:150px;
}

#header {
    position:relative;
    -moz-background-clip:border;
    -moz-background-origin:padding;
    -moz-background-size:auto auto;
    background-color:transparent;
    background:url(images/KMIAFS_banner.jpg) center top no-repeat;
    height:150px;
}

#menu {
    clear:left;
    float:left;
    padding:0;
    border-top:5px solid #f52620;
    width:100%;
    overflow:hidden;
    height:70px;
}


#menu ul {
    float:left;
    margin:0;
    padding:0;
    list-style:none;
    position:relative;
    left:50%;
    text-align:center;
}

#menu ul li {
    display:block;
    float:left;
    list-style:none;
    margin:0;
    padding:0;
    position:relative;
    right:50%;
    font-size:16px;
    font-family:Verdana, Geneva, sans-serif!important;
    font-weight:bold;
}

#menu ul li a {
    display:block;
    float:left;
    margin:0 2px 0 0;
    padding:10px 20px 6px 20px;
    background:#003a72;
    text-decoration:none;
    color:#FFF;
}

#menu ul li a:hover {
    padding:15px 20px 6px 20px;
    background-color:#999;
}

#menu ul li.active a, #menu ul li.active a:hover {
     color:#CCC;
}

#content-container {
    min-height:100%;
    height:100%;
    margin:0 auto;
    width:1000px;
}

#content {
    clear:left;
    float:left;
    width:610px;
    padding:10px;
    margin:0 0 0 30px;
    display:inline;
    background-color:transparent;
}

#content img {
    border:solid 2px #CCC;
    float:left;
    margin:14px 10px 10px 0px;
}

#content h2 {
    margin-bottom:10px;
}

#aside {
    float:right;
    width:290px;
    margin:0 40px 0 0px;
    display:inline;
    background-color:transparent;
}

#aside p {
    color:#CCC;
}

#aside h3 {
    padding-bottom:20px;
}

#aside .box {
    margin-bottom:20px;
    padding:20px;
    color:#fff;
    background-color:#336699;
    -webkit-border-radius:20px;
    -moz-border-radius:20px;
}

#footer {
    position:relative;
    height:70px;
    width:100%;
    border-top:5px solid #f52620;
    background:url(images/ftr_rpt.jpg) repeat-x;
    text-align:center;
    color:#FFF;
    margin:0 auto;
    margin-top:-70px;
    clear:both;
}

#footer a {
    color:#FFF;
    text-decoration:none!important;
    padding:-5px;
}

#footer a:hover {
    color:#CCC;
}

So what am I missing here?
Here's the site: http://www.erisdesigns.net/Stage/McCampbellInsurance/index.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深空失忆 2024-09-14 05:12:37

设置#wrapper{margin-bottom:-70px;position:relative;}并删除padding-bottom

然后在包装器底部添加

并添加 .spacer{height:70px;clear:both;} 像这样添加到你的 css 中:

<div id="wrapper">
...
stuff here
...
<div class="spacer"></div>
</div>
<div id="footer">
 <p>Footer content</p>
</div>

这通常是我的做法。它可能不完全是您想要的,但它可能会为您指明正确的方向。

Set #wrapper{margin-bottom:-70px;position:relative;} and remove padding-bottom.

Then add a <div class="spacer"></div> at the bottom of your wrapper and add .spacer{height:70px;clear:both;} to your css like so:

<div id="wrapper">
...
stuff here
...
<div class="spacer"></div>
</div>
<div id="footer">
 <p>Footer content</p>
</div>

This is usually how I do it. It might not be exactly what you want but it might point you in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文