【问题标题】:Bootstrap sticky footer with image带图像的 Bootstrap 粘性页脚
【发布时间】:2015-12-17 13:39:00
【问题描述】:

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

  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>

【问题讨论】:

    标签: html css twitter-bootstrap-3 footer sticky


    【解决方案1】:

    在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;   
    }
    

    这样图像将始终位于底部,旭日形在内容后面,草在页脚后面

    【讨论】:

    • 工作就像一个魅力。谢谢梅林!
    猜你喜欢
    • 2014-09-09
    • 2014-07-30
    • 2014-03-08
    • 1970-01-01
    • 2012-12-28
    • 2013-07-31
    • 1970-01-01
    • 2023-03-09
    • 2011-05-19
    相关资源
    最近更新 更多