首 页
网络学院
视频教程
资源下载
HOT
实例教程
图文教程
专题中心
学习社区
繁體中文
当前位置:
首页
>
图文教程
>
网页制作
>
CSS样式表
> Float 菜单水平居中简单方法
CSS样式表
用css实现图片垂直居中的使用技巧
CSS List Grid Layout 图片垂直居中
IE6网页神奇BUG
Marquee高级用法实例代码
web标准知识——从p开始,循序渐进
web标准知识——用途相似的标签
html链接与文本标签们
当标题不能显示完整的解决方法
详解链接的rel与target区别
使css兼容IE8的小技巧
CSS 首字母大写代码
CSSvista可同时在IE和Fifrefox调试的CSS编辑提供下载
css font缩写总结附实例
css下margin、padding、border、background和font缩写示例
用CSS来控制图片显示大小的代码
css下划线颜色一句话代码
css常见问题解决方法小结
relative absolute无法冲破的等级问题解决
div总是被select遮挡的解决方法
CSS文字截取功能实现代码
No.
«
‹
46
47
48
49
›
»
技术文章搜索
关键字
CSS样式表 中的 Float 菜单水平居中简单方法
出处:
互联网
整理:
软晨网(RuanChen.com)
发布:
2010-01-10
浏览: 141 ::
收藏到网摘: 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
登陆
还没注册?