"Simple Sticky Top"
Bootstrap 3.3.0 Snippet by guillermoescalona@gmail.com

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="wrapper"> <div class="header"> Header </div> <div class="nav"> Navigation </div> <div class="content"> <p>Candy canes tart pie biscuit. Cupcake liquorice cake dessert tootsie roll applicake pastry. Soufflé chocolate bar macaroon powder macaroon fruitcake donut. Apple pie biscuit wypas toffee caramels wafer lollipop cotton candy. Sweet roll apple pie chupa chups tart bonbon. Croissant carrot cake gummi bears. Sweet roll wypas macaroon fruitcake gummi bears halvah tootsie roll faworki. Wypas halvah dessert carrot cake candy canes tiramisu jelly beans gingerbread. Sweet tootsie roll pie wypas macaroon jelly-o oat cake sesame snaps dessert. Icing tootsie roll gummies topping. Chocolate chocolate cake marshmallow jujubes. Liquorice lemon drops tart. Jujubes gingerbread toffee candy canes.</p> <p>Cheesecake gummies applicake cotton candy dragée wafer candy canes sugar plum sweet roll. Applicake gummi bears wafer bonbon tiramisu wypas. Chocolate cake sweet roll faworki jujubes dragée liquorice chocolate. Sugar plum halvah marzipan apple pie. Tootsie roll faworki bonbon candy canes croissant topping jelly-o tootsie roll topping. Lemon drops tiramisu chocolate. Bonbon lemon drops brownie danish. Bear claw jelly soufflé brownie dragée wafer chocolate sesame snaps. Apple pie donut jelly-o chupa chups croissant jelly-o powder gingerbread chocolate. Lollipop cupcake sweet roll chocolate cake bear claw sweet roll powder applicake oat cake. Jujubes chupa chups jujubes liquorice danish bonbon apple pie topping. Lollipop jujubes halvah carrot cake jelly-o cookie.</p> <p>Powder marshmallow bear claw topping. Chocolate bar icing brownie jujubes pie croissant chupa chups. Tootsie roll fruitcake candy. Tootsie roll jelly-o caramels candy. Gingerbread chocolate cake lemon drops. Pie toffee chupa chups brownie marshmallow cupcake croissant bear claw pudding. Ice cream oat cake marshmallow. Chocolate chocolate oat cake caramels toffee. Sesame snaps brownie cookie candy donut wypas wypas icing. Wypas sweet candy canes apple pie. Croissant gingerbread faworki. Gingerbread pie caramels halvah tiramisu carrot cake lollipop sesame snaps.</p> <p>Jujubes icing carrot cake powder jelly-o sesame snaps toffee pie jelly-o. Carrot cake sugar plum chupa chups bonbon toffee sweet roll topping jujubes cotton candy. Pie sweet roll tart chocolate bar toffee. Apple pie pastry gummies gummi bears jelly-o jujubes. Danish bear claw biscuit croissant. Muffin jujubes jujubes. Sesame snaps oat cake jelly-o jelly gummi bears bear claw. Bear claw halvah sweet roll jujubes faworki lollipop tart wafer tart. Applicake ice cream wafer gummi bears bear claw liquorice caramels marzipan bonbon. Donut cotton candy candy chocolate dessert cookie faworki. Jelly powder applicake jelly beans. Biscuit halvah dessert pie gingerbread powder fruitcake. Pudding fruitcake brownie applicake danish. Danish danish sweet roll.</p> <p>Wafer jelly tiramisu cotton candy faworki cookie bear claw bonbon. Marzipan cheesecake sugar plum pudding croissant cookie wafer. Bonbon dessert toffee gingerbread jelly beans tart tiramisu marzipan. Soufflé lemon drops wypas sweet roll apple pie ice cream. Topping lollipop cake soufflé oat cake toffee candy canes biscuit sweet. Tootsie roll bear claw dragée fruitcake chupa chups marzipan sweet roll. Wafer candy candy dragée jelly beans muffin marzipan. Oat cake bear claw lollipop jujubes cake macaroon biscuit candy canes. Chocolate cake halvah tart muffin gummi bears. Chocolate cake faworki bear claw oat cake macaroon. Candy croissant marzipan macaroon apple pie. Cake ice cream jelly.</p> <p>Cheesecake gummies applicake cotton candy dragée wafer candy canes sugar plum sweet roll. Applicake gummi bears wafer bonbon tiramisu wypas. Chocolate cake sweet roll faworki jujubes dragée liquorice chocolate. Sugar plum halvah marzipan apple pie. Tootsie roll faworki bonbon candy canes croissant topping jelly-o tootsie roll topping. Lemon drops tiramisu chocolate. Bonbon lemon drops brownie danish. Bear claw jelly soufflé brownie dragée wafer chocolate sesame snaps. Apple pie donut jelly-o chupa chups croissant jelly-o powder gingerbread chocolate. Lollipop cupcake sweet roll chocolate cake bear claw sweet roll powder applicake oat cake. Jujubes chupa chups jujubes liquorice danish bonbon apple pie topping. Lollipop jujubes halvah carrot cake jelly-o cookie.</p> <p>Powder marshmallow bear claw topping. Chocolate bar icing brownie jujubes pie croissant chupa chups. Tootsie roll fruitcake candy. Tootsie roll jelly-o caramels candy. Gingerbread chocolate cake lemon drops. Pie toffee chupa chups brownie marshmallow cupcake croissant bear claw pudding. Ice cream oat cake marshmallow. Chocolate chocolate oat cake caramels toffee. Sesame snaps brownie cookie candy donut wypas wypas icing. Wypas sweet candy canes apple pie. Croissant gingerbread faworki. Gingerbread pie caramels halvah tiramisu carrot cake lollipop sesame snaps.</p> </div> </div>
body { margin: 0 auto; padding: 0; } .header { padding: 20px 0; background-color: #333; } .nav { padding: 25px 0; background-color: slategrey; position: -webkit-sticky; top: 45px; z-index: 1; } .header, .nav { text-align: center; color: #fff; } .content { width: 600px; margin: 10px auto 100px; } .sticky { position: fixed; width: 100%; padding: 15px 0; left: 0; top: 0; z-index: 100; border-top: 0; -moz-transition: fadeIn .4s; -o-transition: fadeIn .4s; -webkit-transition: fadeIn .4s; transition: fadeIn .4s; }
$(document).ready(function() { // grab the initial top offset of the navigation var stickyNavTop = $('.nav').offset().top; // our function that decides weather the navigation bar should have "fixed" css position or not. var stickyNav = function(){ var scrollTop = $(window).scrollTop(); // our current vertical position from the top // if we've scrolled more than the navigation, change its position to fixed to stick to top, // otherwise change it back to relative if (scrollTop > stickyNavTop) { $('.nav').addClass('sticky visible'); } else { $('.nav').removeClass('sticky visible'); } }; stickyNav(); // and run it again every time you scroll $(window).scroll(function() { stickyNav(); }); });

Related: See More


Questions / Comments: