2015-10-01

A Example for Bootstrap Affix


<html>
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <style>
  /* Note: Try to remove the following lines to see the effect of CSS positioning */
  .affix {
      top: 0;
      width: 100%;
  }

  .affix + .container-fluid {
      padding-top: 70px;
  }

  .navbar-inverse {
    background-color: #9C5D5D;
    border-color: #9C5D5D;
  }

  .navbar {
    border-radius: 0px;
    margin-bottom: 0px;
  }

  #se3 {padding-top:50px;height:400px;color: #fff; background-color: #4F9D9D}
  #se1 {padding-top:50px;height:400px;color: #fff; background-color: #FF5151}
  #se2 {padding-top:50px;height:400px;color: #fff; background-color: #8E8E8E}
  </style>
</head>
<body data-spy="scroll" data-target=".navbar" data-offset="50">

<div class="container-fluid" style="background-color:#2894FF;color:#ffffff;height:200px;">
  <h1>Bootstrap Affix Example</h1>
  <h3>Fixed (sticky) navbar on scroll</h3>
</div>

<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197">
  <div class="container-fluid">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>                        
      </button>
    </div>
    <div>
      <div class="collapse navbar-collapse" id="myNavbar">
        <ul class="nav navbar-nav">
          <li><a href="#se1">Product</a></li>
          <li><a href="#se2">Price</a></li>
          <li><a href="#se3">Contact Us</a></li>
        </ul>
      </div>
    </div>
  </div>
</nav>

<div id="se1" class="container-fluid">
  <h1>It is Bootstrap</h1>
  <h1>It is Bootstrap</h1>
  <h1>It is Bootstrap</h1>
  <h1>It is Bootstrap</h1>
  <h1>It is Bootstrap</h1>
</div>

<div id="se2" class="container-fluid">
  <h1>I am Bootstrap</h1>
  <h1>I am Bootstrap</h1>
  <h1>I am Bootstrap</h1>
  <h1>I am Bootstrap</h1>
</div>

<div id="se3" class="container-fluid">
  <h1>It is the Example of Affix</h1>
  <h1>It is the Example of Affix</h1>
  <h1>It is the Example of Affix</h1>
  <h1>It is the Example of Affix</h1>
</div>
</body>
</html>

No comments: