仅使用jquery处理Sticky Footer(子页脚和主页脚底部)

时间:2017-09-27 00:18:46

标签: jquery css

实际上,我有两个具有动态内容的页脚。这就是为什么我使用jquery使子页脚和主页脚粘。 现在页脚粘贴工作,但在窗口调整大小时,主页脚的高度增加。请看脚本。我想,我有脚本问题。我在代码底部添加了脚本。

com.twilio.twiml.Number number = new com.twilio.twiml.Number.Builder("XXXXXXXXXX").build();
                    return new VoiceResponse.Builder()
                            .say(say)
                            .dial(new Dial.Builder().number(number).build())
                            .hangup(new Hangup())
                            .build();

1 个答案:

答案 0 :(得分:1)

根据评论编辑:

  • 完全删除JS并将以下CSS属性添加到动态页脚:

bottom: 46px; - >静态页脚的高度

<强> Resizable working Fiddle

以下代码段:

html {
  position: relative;
  height: 100%;
}

body {
  /* Margin bottom by footer height */
}

.footer {
  position: absolute;
  bottom:46px;
  width: 100%;
  /* Set the fixed height of the footer here */
  background-color: #000;
  text-align: center;
  color: #fff;
}

.footer-bottom {
  padding: 3px 0;
  position: absolute;
  bottom: 0;
  background-color: green;
  text-align: center;
  width: 100%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<body class="page-body">
  <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
    <a class="navbar-brand" href="#">Fixed navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarCollapse">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
      <form class="form-inline mt-2 mt-md-0">
        <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
      </form>
    </div>
  </nav>
  <!--[ container ] -->
  <div class="container">
    content here
  </div>
  <!--[ footer ] -->
  <div class="footer">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste neque deserunt alias, hic incidunt sequi reiciendis, quis nobis accusantium, quod iure, ipsum soluta architecto maxime quas veritatis sint animi repellat!</p>
  </div>
  <div class="footer-bottom">
    <p>footer Bottom</p>
  </div>