Team:Tianjin/frame/modeling
From 2012.igem.org
(Difference between revisions)
Line 28: | Line 28: | ||
}); | }); | ||
}); | }); | ||
+ | </script> | ||
+ | |||
+ | <script type="text/javascript"> | ||
+ | $(function(){ | ||
+ | //获取要定位元素距离浏览器顶部的距离 | ||
+ | var navH = $(".modmenu").offset().top; | ||
+ | //滚动条事件 | ||
+ | $(window).scroll(function(){ | ||
+ | //获取滚动条的滑动距离 | ||
+ | var scroH = $(this).scrollTop(); | ||
+ | //滚动条的滑动距离大于等于定位元素距离浏览器顶部的距离,就固定,反之就不固定 | ||
+ | if(scroH>=navH){ | ||
+ | $(".modmenu").css({"position":"fixed","top":0,"margin":"5px","width":"170px";}); | ||
+ | }else if(scroH<navH){ | ||
+ | $(".modmenu").css({"position":"static","margin":"5px","width":"170px"}); | ||
+ | } | ||
+ | console.log(scroH==navH); | ||
+ | }) | ||
+ | }) | ||
</script> | </script> | ||
Line 81: | Line 100: | ||
</style> | </style> | ||
- | <div | + | <div class="modmenu" style="float:left;"> |
<div class="menu_list" id="secondpane"> <!--Code for menu starts here--> | <div class="menu_list" id="secondpane"> <!--Code for menu starts here--> | ||
<p class="menu_head">Header-1</p> | <p class="menu_head">Header-1</p> |
Revision as of 16:53, 20 September 2012