With the help of Bootstrap we can create a Scrollspy function.The Scrollspy plugin is used to automatically update links in a navigation list based on scroll position. According to the below example, i am  using data-spy=scroll it is used to scolling element, after then I have used data-target attribute. The Target data attribute is used to make  id or class name of the navigation bar.
<!DOCTYPE html>
<html>
<head>
  <title>Evon-tec</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>
  .test {
      position: relative; 
      top: 50px;
      height: 240px;
      overflow: auto;
      font-size: 28px;
  }
  #section1 {color: #fff; background-color: #1E88E5;}
  #section2 {color: #fff; background-color: #673ab7;}
  #section3 {color: #fff; background-color: #ff9800;}
  #section41 {color: #fff; background-color: #00bcd4;}
  #section42 {color: #fff; background-color: #009688;}
  </style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <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>
      <a class="navbar-brand" href="#">IT & network Company </a>
    </div>
    <div>
      <div class="collapse navbar-collapse" id="myNavbar">
        <ul class="nav navbar-nav">
          <li><a href="#section1">Box-1</a></li>
          <li><a href="#section2">Box-2</a></li>
          <li><a href="#section3">Box-3</a></li>
          <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Section 4 <span class="caret"></span></a>
            <ul class="dropdown-menu">
              <li><a href="#section41">Text 4-1</a></li>
              <li><a href="#section42">Text 4-2</a></li>
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </div>
</nav>    
<div data-spy="scroll" data-target=".navbar" data-offset="12" class="test">
  <div id="section1">
    <div class="container-fluid">
      <h1>Evon</h1>
      <p>We are a team of 200+ technology evangelists, simply in love with the town we are headquartered in.  </p>
      <p>Try to scroll this section and look at the navigation bar while scrolling!</p>
    </div>
  </div>
  <div id="section2">
    <div class="container-fluid">
      <h1>Ericsson-network</h1>
      <p>Like most of our kind, we are a custom software development company.  </p>
      <p>The company's offerings comprise services, software and infrastructure</p>
    </div>  
  </div>
  <div id="section3">
    <div class="container-fluid">
      <h1>Ericsson-pvt</h1>
      <p>Ericsson is a Swedish multinational provider of communication technology and services.  in information and communications technology </p>
      <p>We believe that the Project Requirement Document is just a small part of contribution from your side on the road to success</p>
    </div>  
  </div>
  <div id="section41">
    <div class="container-fluid">
      <h1>Microsoft</h1>
      <p>We need you there at every step of project execution. We require long meetings with you. </p>
      <p>At Microsoft our mission and values are to help people and businesses </p>
    </div>  
  </div>
  <div id="section42">
    <div class="container-fluid">
      <h1>Apple</h1>
      <p>Try to scroll this section and look at the navigation bar while scrolling!</p>
      <p>At Microsoft our mission and values are to help people and businesses throughout</p>
    </div>  
  </div>
</div>
</body>
</html>
                       
                    
0 Comment(s)