Bootstrap 带有图片的粘性页脚

Bootstrap sticky footer with image

我想要实现的是一个带有粘性页脚的页面,这是一个矢量岛。

  1. 小岛总是在页面的底部,但是当浏览器高度太小时它会调用垂直滚动。

  2. 岛的后面是朝阳,然后落在所有页面内容的后面。这是相当大的,大约 1417px 高。不过这不会影响垂直滚动。

这是我目前的情况,我已经被困了几个小时了!任何帮助将不胜感激。

<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <meta content="IE=edge" http-equiv="X-UA-Compatible">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <meta content="" name="description">
  <meta content="" name="author">
  <link href="../../docs-assets/ico/favicon.png" rel="shortcut icon">

  <title>Sticky Footer Template for Bootstrap</title><!-- Latest compiled and minified CSS -->
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
  <style type="text/css">

  html,
  body {
  height: 100%;
  background-color: #6ec8e4;
  }

  #wrap {
  min-height: 100%;
  height: auto;
  }


  .testBox{
  height: 300px;
  width: 100%;
  background: red;
  margin: 20px 0;
  }

  .footer-image-container {
  margin: 0 auto;
  position: absolute;
  width: 100%;
  height: 1417px;
  }

  .footer-image {
  position: absolute;
  bottom: 0;
  z-index: -1;
  }

  </style>
</head>

<body>
  <!-- Wrap all page content here -->

  <div id="wrap">
    <!-- Begin page content -->

    <div class="container">
      <div class="page-header">
        <h1>Sticky footer</h1>
      </div>

      <div class="row">
        <div class="testBox"></div>
      </div>

      <div class="row">
        <div class="testBox"></div>
      </div>

      <div id="footer">
        <div class="footer-image-container"><img class="img-responsive footer-image" src="http://i.imgur.com/wSNrfJD.png">
        <img class="img-responsive footer-image" src="http://i.imgur.com/alDv0tE.png"></div>
      </div>
    </div>
  </div><!-- Bootstrap core JavaScript
  ================================================== -->
  <!-- Placed at the end of the document so the pages load faster -->
  <!-- Latest compiled and minified JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>

最好用css中的图片作为背景图片:

https://jsfiddle.net/6t9vxq1o/1/

.body{
    height:100%;
    background: url(http://i.imgur.com/wSNrfJD.png) no-repeat center bottom;   
}
#wrap{
    background:url(http://i.imgur.com/alDv0tE.png) no-repeat center bottom;   
}

这样图像将始终在底部,阳光在内容后面,草在页脚后面