javascript - 粘性页脚不粘在 AngularJS 中

标签 javascript html css angularjs

我在一个 Angular 网站上工作,我试图在所有 View 中实现一个粘性页脚,但是当内容超过窗口大小时页脚停止粘附并且出现滚动条。我尝试了很多不同的方法,比如在我的所有内容周围添加一个包装器,添加一个 .push div 但似乎没有任何效果。有没有人遇到过这个问题并修复它或知道某种插件等。我可以用来完成这项工作吗? with my current css/html this is what happens on pages where content exceeds the size of the window

这是我的代码:

<body ng-app="noteSnapApp">
<!--[if lt IE 7]>
  <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

<!-- Add your site or application content here -->
  <div style="min-height: 55px;" ng-controller="NavCtrl" class="navbar navbar-default navbar-static-top ns-navbar ns-hide-nav">
      <div  class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">NoteSnap</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a style="padding: 0" class="navbar-brand" href="/feed"><img class="img-responsive" src="images/notesnap_logo.png" width="165"></a>
        </div>
          <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
              <li ng-hide="logoutBtn" class="ns-logout"><a ng-click="logOut()" href="">Logout</a></li>
            </ul>
          </div>
      </div>
    </div>

    <div ng-view></div>

    <div class="banner-footer">
        <a href="http://bit.ly/1ul3gG7"><img class="img-responsive" src="images/banner.png" width="100%"></a>
    </div>

        <div id="fb-root">
        </div>
</body>

还有我的CSS:

html, body {height: 100%;}
html{
font-family: 'museo_sans100';
color: #333333;
position: relative !important;
min-height: 100%;
}

body {
background-color: transparent;
margin-bottom: 90px;
}

 .banner-footer {
position: fixed;
bottom: 0;
width: 100% ;
height: 90px;
clear: both;
}

欢迎和赞赏任何和所有建议,我也愿意尝试 jQuery/javascript 解决方法,基本上任何可行的方法!

最佳答案

还有 Bootstrap solution ,实际上并不需要安装 Bootstrap 框架,只需以下结构:

HTML:

<!-- Begin page content -->
<div class="container">
  <div class="page-header">
    <h1>Sticky footer</h1>
  </div>
  <p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS.</p>

</div>

<div class="footer">
  <div class="container">
    <p class="text-muted">Place sticky footer content here.</p>

  </div>
</div>

CSS:

/* Sticky footer styles
-------------------------------------------------- */
html {
  position: relative;
  min-height: 100%;
}
body {
  /* Margin bottom by footer height */
  margin-bottom: 60px;
}
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  /* Set the fixed height of the footer here */
  height: 60px;
  background-color: #f5f5f5;
}


/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */

.container {
  width: auto;
  max-width: 680px;
  padding: 0 15px;
}
.container .text-muted {
  margin: 20px 0;
}

继承人 a working Fiddle用长文本显示页面滚动时的行为。

关于javascript - 粘性页脚不粘在 AngularJS 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26197743/

相关文章:

javascript - Angular js 无法正常工作解决方法

javascript - 为什么未定义被添加到我的过滤列表中?

css - IE 中奇怪的 Bootstrap 3 文本换行问题

CSS - 嵌套表格边框显示。我该如何阻止呢?

javascript - Wordpress WooCommerce 产品轮播不显示图片

javascript - 获取 WebBrowser 控件的正确页面高度

javascript - 如何根据元素的宽度和数量调整父 div 的大小

html - 使用 CSS 伪元素使用内容来表示图标

javascript - 如何缩放 Canvas 并保持其在屏幕上的位置?

html - 带有缩略图的CSS下拉菜单