【问题标题】:How to stop a div above the footer如何在页脚上方停止 div
【发布时间】:2013-04-29 17:28:23
【问题描述】:

我已经阅读了很多关于这个问题的帖子,但没有一个可以帮助解决我遇到的问题。我想让页面一侧的 nav_bar 停在页脚的右侧(内容 div 结束的确切位置。)对不起,我对 javascript/jQuery 不是很好。哈哈

这是我的导航代码:

<div id="section">
        <div id="navbar">
            <div id="navbar_contents">
              <ul>
                <li><a href="#"><img src="images/nav_bar/nav_top.jpg" width="107" height="55" alt="top"></a></li>
                <li><a href="#"><img src="images/nav_bar/nav_portfolio.jpg" width="107" height="55" alt="portfolio"></a></li>
                <li><a href="#"><img src="images/nav_bar/nav_about.jpg" width="107" height="55" alt="about"></a></li>
                <li><a href="#"><img src="images/nav_bar/nav_contact.jpg" width="107" height="55" alt="contact"></a></li>
                <li><a href="#"><img src="images/nav_bar/nav_resume.jpg" width="107" height="55" alt="resume"></a></li>
              </ul>
            </div>
         </div>
  <div id="content">
  <h1>THE TOP</h1>
  <div id="clear">
  </div>
  </div>
</div>

和 CSS:

#section #navbar {
    background-color: #FFF;
    height: auto;
    width: auto;
    border: 1px solid #000;
    float: left;
    -moz-box-shadow: 0px 0px 25px 2px #000000;
    -webkit-box-shadow: 0px 0px 25px 2px #000000;
    box-shadow: 0px 0px 25px 2px #000000;
    -webkit-border-radius: 8px;
    -webkit-border-bottom-right-radius: 20px;
    -webkit-border-bottom-left-radius: 20px;
    -moz-border-radius: 8px;
    -moz-border-radius-bottomright: 20px;
    -moz-border-radius-bottomleft: 20px;
    border-radius: 8px;
    border-bottom-right-radius: 20px;
    border-bottom-left-radius: 20px;
    padding-right: 23px;
    position: fixed;
}

#section #navbar #navbar_contents {
    width: auto;
    height: auto;
}

#section #navbar ul {
    list-style-type: none;
}

#section #content {
    background-color: #FFF;
    height: 2000px;
    width: 610px;
    border: 1px solid #000;
    float: left;
    margin-left: 200px;
    -moz-box-shadow: 0px 0px 25px 2px #000000;
    -webkit-box-shadow: 0px 0px 25px 2px #000000;
    box-shadow: 0px 0px 25px 2px #000000;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    margin-bottom: 20px;
    padding-left: 40px;
    padding-top: 30px;
}

非常感谢您的帮助!

【问题讨论】:

  • 你能提供一张你想要的基本清晰的图画吗?
  • 如果您提供图片,编写示例代码会容易得多

标签: javascript jquery css html sticky


【解决方案1】:

更新

更改您的 CSS:

#section {
width: 940px;
height: 1500px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-left: 0px;
}

您的margin-top 导致导航栏被向下推得太远了。

【讨论】:

  • 你的意思是:$("#navbar").height($("#content").height()); ?
  • @roasted 我确实做到了,正在更新
  • 我不想将 nav_bar div 的大小调整为内容 div 的大小,我想让 nav_bar div 在内容 div 结束的地方停止滚动,这样它就不会重叠页脚。
  • @PixelReaper 我假设 #navbar 是一个容器,因此您只需在更改容器高度后将 overflow: auto 设置为容器
  • 好的。是的,该代码似乎不适用于导航栏。对不起,我真的很陌生。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-19
  • 2020-10-16
相关资源
最近更新 更多