首 页
网络学院
视频教程
资源下载
HOT
实例教程
图文教程
专题中心
学习社区
繁體中文
当前位置:
首页
>
图文教程
>
网页制作
>
CSS样式表
> Float 菜单水平居中简单方法
CSS样式表
CSS网页设计 IE8和IE7共存
CSS2 打印属性让打印HTML文档不出问题
制作网页中设计段落缩进的方法
CSS border 属性使用说明
CSS border-style 属性使用方法
CSS border-color 属性使用方法
CSS border-width 属性使用教程
CSS padding属性定义边内补白
CSS margin 属性定义边外补白
网页布局教程 掌握CSS网页布局属性
css 背景样式属性说明
span margin 设置生效
html 滚动条在IE6和IE7中兼容性问题
IE6 两个div有间隙的问题(IE 3px bug)
CSS 数字和字母将容器撑大问题解决
换个角度看页面重构中的语义化
DIY属于个人开发使用的CSS Reset
CSS 空格引起网页布局间距问题
CSS 网页制作时遇到问题的快速参考技巧
css li 去掉点的样式写法
No.
«
‹
20
21
22
23
›
»
技术文章搜索
关键字
CSS样式表 中的 Float 菜单水平居中简单方法
出处:
互联网
整理:
软晨网(RuanChen.com)
发布:
2010-01-10
浏览: 100 ::
收藏到网摘: n/a
简单的CSS 下拉导航菜单实现代码
网页设计中常用的19个Web安全字体
我这里还有更简单的办法,先展示:
其实我外面应该再套一个div,但为了减少碳排放,舍弃。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> body{font-family:Verdana,Arial,sans-serif;font-size:12px;margin:120px auto;text-align:center;} ul{margin:0;padding:0;list-style:none;} #navigation{display:inline-block;border:solid 1px red;padding:20px;} #navigation li{height:30px;float:left;} #navigation li a{float:left;height:30px;line-height:30px;padding:0 23px;background:#97C099;} #navigation li a:hover{background:#59c099;color:#fff;} </style> <!--[if lte IE 7]><style type="text/css">#navigation{display:inline;}</style><![endif]--> <title>float菜单局中一法</title> </head> <body> <ul id="navigation"> <li><a href="#">Home</a></li> <li><a href="#">News</a></li> <li><a href="#">Store</a></li> <li><a href="#">Group</a></li> <li><a href="#">Community</a></li> <li><a href="#">Help</a></li> </ul> </body> </html>
提示:您可以先修改部分代码再运行
其中最为关键的是这一句:
<!--[if lte IE 7]><style type="text/css">#navigation{display:inline;}</style><![endif]-->
为了照顾较低版本IE,这里使用了条件注释,感觉在IE7以下中,display:inline;的作用就相当于inline-block;。
根据上面代码进化而来的滑动门导航:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> body{font-family:Verdana,Arial,sans-serif;font-size:12px;margin:120px auto;text-align:center;} ul{margin:0;padding:0;list-style:none;} #navigation{display:inline-block;padding:20px;border:solid 1px red;} #navigation li{height:30px;float:left;} #navigation li a{float:left;background:#97C099 url(http://home.blueidea.com/attachment/200903/13/381636_1236958262fsCk.gif) left top no-repeat;padding-left:27px;height:30px;overflow:hidden;} #navigation li a span{height:30px;float:left;background:url(http://home.blueidea.com/attachment/200903/13/381636_1236958262fsCk.gif) right -352px no-repeat;padding-right:27px;line-height:33px;cursor:hand;} #navigation li a:hover,#navigation li.current a{background-position:left -176px;color:#009;background-color:#8597B5;} #navigation li a:hover span,#navigation li.current a span{background-position:right -528px;} #navigation li.current a{font-weight:bold;} </style> <!--[if lte IE 7]><style type="text/css">#navigation{display:inline;}</style><![endif]--> <title>根据上面代码升级为滑动门样式</title> </head> <body> <ul id="navigation"> <li><a href="#"><span>Home</span></a></li> <li><a href="#"><span>News</span></a></li> <li class="current"><a href="#"><span>Store</span></a></li> <li><a href="#"><span>Group</span></a></li> <li><a href="#"><span>Community</span></a></li> <li><a href="#"><span>Help</span></a></li> </ul> </body> </html>
提示:您可以先修改部分代码再运行
其中,这两句有必要说明一下,以免被认为是多余的:
复制代码
代码如下:
#navigation li a{overflow:hidden;} /* 隐藏掉IE5.5、6多掉的那3px,不是3px bug哈!因为height:30px;line-height:33px; 在IE5.5、6中高度就是33px了。 */
#navigation li a span{cursor:hand;}/* 照顾IE 5.5、6、7鼠标放在span上面不呈手型的bug。此外,IE5.5不支持cursor:pointer;但IE全版本都认识cursor:hand;*/
完工了,缺点就是,写那一行条件注释,对于有xhtml洁癖的人来说,就像眼里的沙子,想除掉,那就使用hack也无妨!呵呵!
在safari4,chorme,opera10,ie5.5、5、6、7,ff3中均暂未发现问题。
简单的CSS 下拉导航菜单实现代码
网页设计中常用的19个Web安全字体
评论 (0)
All
登陆
还没注册?