自适应宽度的二级横向CSS菜单

新收获

昨天替人弄一个二级横向菜单。做完之后,习惯性地在IE6中测试了一下,结果发现宽度一如即往的没有自适应。

解决:对目标进行浮动,使其自适应宽度。


#menu a{ float:left; }

IE6

当前:


<!--[if lt IE 7]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
    $('#menu li').bind('mouseenter mouseleave',function(){
    	$(this).toggleClass('hover');
    })
});
</script>
<![endif]-->

备选:


<!--[if IE 6]><style type="text/css">body{behavior:url("/style/csshover.htc");}</style><![endif]-->

注:

附带动画版,限制了宽度,适应性更高。

HTML Code

预览/下载:

/css-html/auto-fit-width-horizontal-css-menu.htm

/css-html/auto-fit-width-horizontal-css-menu-animated-version.htm

posted @ 2009-09-14 22:09  ambar  阅读(3184)  评论(1编辑  收藏  举报