JS菜单条智能定位效果
2014-01-16 16:41
197 查看
JS仿淘宝详情页菜单条智能定位效果
2014-01-15 15:40 by 龙恩0707, 1366 阅读, 9 评论, 收藏, 编辑类似于淘宝详情页菜单条智能定位 对于每个人来说并不陌生!如下截图所示:红色框的那部分!
View Code
/**
* JS仿淘宝详情页菜单条智能定位效果
* constructor SmartFloat
* @author tugenhua
* @time 2014-1-15
*/
function SmartFloat(options) {
this.config = {
targetElem : '#nav' // 要定位的dom节点
};
this.cache = {};
this.init(options);
}
SmartFloat.prototype = {
constructor: SmartFloat,
init: function(options){
this.config = $.extend(this.config, options || {});
var self = this,
_config = self.config,
_cache = self.cache;
var top = $(_config.targetElem).offset().top,
pos = $(_config.targetElem).css('position'),
isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;
$(window).scroll(function(){
var winTop = $(this).scrollTop();
if(winTop >= top) {
if(!isIE6) {
$(_config.targetElem).css({
position: 'fixed',
top: 0
});
}else {
$(_config.targetElem).css({
position: 'absolute',
top: winTop
});
}
}else {
$(_config.targetElem).css({
position: pos,
top: top
});
}
});
}
};
// 页面初始化
$(function(){
new SmartFloat({
});
});
demo下载
相关文章推荐
- 仿淘宝商城左侧分类导航菜单效果(平滑,高效,智能定位,jquery版)
- JS仿淘宝详情页菜单条智能定位效果
- 仿淘宝商城左侧分类导航菜单效果(平滑,高效,智能定位,jquery版)
- JS仿淘宝详情页菜单条智能定位效果
- JS+CSS实现简单滑动门(滑动菜单)效果
- JS打字效果的动态菜单代码分享
- 效果直逼flash的Div+Css+Js菜单
- Ferris教程学习笔记:js示例5.7 自定义右键菜单,请在页面点击右键查看效果。
- JS+CSS实现滑动切换tab菜单效果
- JS实现网站菜单拖拽移位效果的方法
- js页面滚动时层智能浮动定位实现(jQuery/MooTools)
- js实现向右横向滑出的二级菜单效果
- JS实现仿苹果底部任务栏菜单效果代码
- js实现具有高亮显示效果的多级菜单代码
- js实现带缓冲效果的仿QQ面板折叠菜单代码
- js+css多级树形展开效果导航菜单
- [效果]JS折叠菜单-使用方法 (Moo.Fx)
- JS实现选中当前菜单后高亮显示的导航条效果
- js+css实现tab菜单切换效果的方法
- js页面滚动时层智能浮动定位实现(jQuery/MooTools)