横向子菜单栏ul根据其子元素li个数动态获取宽度,并与父li绝对垂直居中的jquery代码段
;(function(window){
$('.menuitem').hover(function(){
$('>a',this).css('background-color','#60AEEC');
$('.subnav',this).show();
$('.subnav',this).width(function(){
return $('.subnav').children("li:visible").width()*$('.subnav').children("li:visible").length;
});
var sleft = $(this).offset().left-($('.subnav').children("li:visible").width()*$('.subnav').children("li:visible").length-150)/2;
$('.subnav',this).offset({left:sleft});
},function(){
if( !$(this).hasClass('selected') )
$('>a',this).css('background-color','transparent');
$('.subnav',this).hide();
});
/*$('.subnav').hover(function(){},function(){
$('>a',this).css('background-color','transparent');
$(this).hide();
});*/
})(window);
最新文章
- 从java文件和CS文件里查询方法使用次数工具
- 关于java中接口定义常量和类定义常量的区别
- PHPStorm 与 XDebug 配置
- Rational Rose 2007 破解版安装过程
- NSString几个函数
- VC文件夹大小(转)
- ServiceStack 介绍
- HDOJ-ACM1023(JAVA)
- Vijos1825 NOI2008 志愿者招募 费用流
- sql server 2000 下载地址
- django generic view - ListView
- HTTP的基本原理
- git format-patch制作内核补丁
- 上海市2019年公务员录用考试笔试合格人员笔试成绩(A类)
- Kotlin入门(6)条件分支的实现
- 洛谷.4114.Qtree1(树链剖分)
- ruby-from-other-languages
- Spring学习笔记四:SpringAOP的使用
- 使用Koa2搭建web项目
- Java 8 Date-Time API概览