We can affix the navbar, When the user scrolls the navbar the header function goes to top and header section fires when the navbar list values are clicked.
<style> .affix { top: 0; width: 100%; } .affix + .container-fluid { padding-top: 70px; } </style> </head> <body> <header class="container-fluid" style="background-color:red;color:white;height:200px;"> <h1>Bootstrap Affix Example</h1> <p>SN ITFunda is a online tutorial which consists of websites to make people learn web technologies with the websites dotnetfunda, techfunda, itfunda, farmingfunda, funddo video etc </p> </header> <nav class="navbar navbar-inverse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">SN ITFunda</a></li> <li><a href="#">DotNetFunda</a></li> <li><a href="#">TechFunda</a></li> <li><a href="#">ITFunda</a></li> </ul> </nav> <div class="container-fluid" style="height:900px;background-color:pink;color:black;"> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> <h1>SN ITFunda</h1> </div> <script> $(document).ready(function () { $(".navbar").affix({ offset: { top: $("header").outerHeight(true) } }); }); </script> </body>
header
section with class value container-fluid
to define the values by giving style as color, background-color and height navbar navbar-inverse
and we have <ul>
element with class value nav navbar-nav
to define the list values as DotNetFunda, TechFunda, ITFunda container-fluid
with style as background-color, color, height and we have defined the values in heading tag<h1>$(".navbar")
which calls the nav element, .affix({offset:{top:("header").outerheight(true) } })
; defines as navbar element to affix the header section , i.e when the user scrolls the element andthen the header section values moves upwardsand displays the navbar and then the navbar list values are clicked then the Header section values are displayed. .affix+container-fluid
as padding-top:70px
defines as when the scroll function is done then list values in the container-fluid
with heading tag <h1>
appear at below of the navbar with 70px. output
Views: 4892 | Post Order: 64