[英]Fixed To Top Menu in Yii Bootstrap
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: JS代码:
<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. 这与Yii完全无关。 Anyway you are looking for this http://tutsme-webdesign.info/bootstrap-3-affix/
无论如何,您都在寻找这个http://tutsme-webdesign.info/bootstrap-3-affix/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.