I need a simple clarification on this, I have a menu. Whenever I scroll Down I need this menu to appear at the side of my page. Please help me doing this.
View:
<div id="fl_menu">
<div class="label">MENU</div>
<div class="menu">
<a href="#" class="menu_item">An menu item</a>
<a href="#" class="menu_item">A long menu item</a>
<a href="#" class="menu_item">Item 3</a>
<a href="#" class="menu_item">Another one</a>
<a href="#" class="menu_item">A really, really long menu item</a>
<a href="#" class="menu_item">Menu item 6</a>
<a href="#" class="menu_item">And one more</a>
<a href="#" class="menu_item">A tiny</a>
</div>
</div>
JS code:
<script>
//STICKY NAV
$(document).ready(function () {
var top = $('#fl_menu').offset().top - parseFloat($('#fl_menu').css('marginTop').replace(/auto/, 100));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#fl_menu').addClass('fixed');
} else {
// otherwise remove it
$('#fl_menu').removeClass('fixed');
}
});
});
</script>
Thanks in advance.
This has absolutely nothing to do with Yii. Anyway you are looking for this http://tutsme-webdesign.info/bootstrap-3-affix/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.