转载:CSS圆角导航的两种不同构建方法
来源:互联网 发布:数控加工编程 编辑:程序博客网 时间:2024/06/05 16:29
简单的两种CSS圆角导航构建方法,简单,但是细节部分还是需要注意下。首先来看第一种:1.利用背景图像构建。准备一张圆角图像,利用CSS定义背景图像,这是最简单的圆角导航。我准备的图像为400px*40px,代码如下: 1<HTML> 2 <HEAD> 3 <TITLE> Navigation </TITLE> 4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD> 5 <style type="text/css">... 6 <!-- 7 * {...}{}{...}{ 8 margin:0; 9 padding:0;10 } 11 body {...}{}{...}{12 font-family: 雅黑,Arial;13 font-size:16px;14 text-align:center;15 }16 a {...}{}{...}{17 text-decoration:none;18 }19 .nav {...}{}{...}{20 float:left;21 width:400px;22 height:40px;23 background: url(http://www.cnblogs.com/images/cnblogs_com/slotbeta/nav.gif) no-repeat center;24 }25 .nav li {...}{}{...}{26 float:left;27 width:100px;28 line-height:40px;29 list-style:none;30 }31 .nav li a {...}{}{...}{32 color:#222;33 font-weight:bold;34 display:block;35 }36 .current {...}{}{...}{37 background:url(http://www.cnblogs.com/images/cnblogs_com/slotbeta/current.gif) no-repeat center;38 }39 -->40 </style>414243 <BODY>44 <div class="nav">45 <ul>46 <li><a href="#" class="current">首页</a></li>47 <li><a href="#">资讯</a></li>48 <li><a href="#">人物</a></li>49 <li><a href="#">互联网</a></li>50 </ul>51 </div>52 </BODY>53</HTML>这里需要注意的是代码*{margin:0;padding:0},如果将该段代码注释掉,那么在IE下正常显示而在FF下出现错位情况;另外就是开始时候我的代码是这样的:.nav li { float:left; list-style:none; } .nav li a { float:left; color:#222; font-weight:bold; display:block; width:75px; line-height:40px; margin:0 0 0 25px; }后来改为.nav li { float:left; width:100px; line-height:40px; list-style:none; } .nav li a { color:#222; font-weight:bold; display:block; }可以看出代码明显少了。2.利用div设置与背景色相同的颜色来“欺骗”眼睛,做到圆角导航1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4<title>navigation</title> 5<style>... 6<!-- 7* {...}{}{...}{ 8margin:0; 9padding:0;10}11body {...}{}{...}{12text-align:center;13font-size:16px;14}15.l {...}{}{...}{16float:left;17}18.r {...}{}{...}{19float:right;20}21.c {...}{}{...}{22clear:both;23}24.w {...}{}{...}{25width:4px;26height:1px;27background:#fff;28overflow:hidden;29}30.h {...}{}{...}{31width:2px;32height:1px;33background:#fff;34overflow:hidden;35}36.o {...}{}{...}{37width:1px;38height:2px;39background:#fff;40overflow:hidden;41}42.red {...}{}{...}{43background:#333;44width:400px;45height:48px;46margin:10px;47}48.nav {...}{}{...}{49float:left;50width:400px;51height:40px;52}53.nav li{...}{}{...}{54float:left;55width:100px;56line-height:40px;57list-style:none;58}59.nav li a {...}{}{...}{60color:#555;61display:block;62font-weight:bold;63text-decoration:none;64}65-->66</style>67</head>6869<body>7071<div class="red">72<div class="l w"></div>73<div class="r w"></div>74<div class="c"></div>75<div class="l h"></div>76<div class="r h"></div>77<div class="c"></div>78<div class="l o"></div>79<div class="r o"></div>80<div class="c"></div>81<div class="nav">82<ul>83<li><a href="#">首页</a></li>84<li><a href="#">资讯</a></li>85<li><a href="#">人物</a></li>86<li><a href="#">互联网</a></li>87</ul>88</div>89<div class="l o"></div>90<div class="r o"></div>91<div class="c"></div>92<div class="l h"></div>93<div class="r h"></div>94<div class="c"></div>95<div class="l w"></div>96<div class="r w"></div>97</div>98</body>99</html>这个方法最先出现在Google的网站导航页面(http://daohang.google.cn ),利用三个4*1px 、2*1px 、 1*2 px 大小的div,并设置相应背景色(这里设置的是白色),通过使用浮动来达到圆角的效果,其中最重要的就是给以上三个div设置overflow:hidden; 。这里只是班门弄斧的做出两个,如果大家有更好的方法,欢迎跟帖交流!注:以上在IE6、7,FF2.0下运行正常。
- 转载:CSS圆角导航的两种不同构建方法
- 【HTML】通过不同的分辨率调用不同的css,两种方法:css本身判断、js调用css
- 【String构建方式】 构建的两种不同的方式
- 自定义导航的两种方法
- css构建两个简单的导航栏
- laszlo方法的两种不同写法
- Singleton的两种不同实现方法.
- CSS清除浮动的两种方法
- jquery修改css的两种方法
- CSS 图片居中的两种方法
- CSS布局的两种方法
- css实现三角形的两种方法
- iOS 导航栏设置颜色的两种方法
- iOS 隐藏导航栏底部线的两种方法
- iOS 设置导航透明的两种方法
- 导航栏顶部悬停的两种方法
- iOS 设置导航透明的两种方法
- iOS 开发中导航栏渐变的两种方法
- [转]++对USB驱动程序的理解
- Silverlight教程第八部分:使用WPF创建一个Digg桌面应用
- 工作了
- 带镣铐的舞者:从两方面看AJAX与B/S
- 使用 System.IO 和 Visual C# 读取文本文件
- 转载:CSS圆角导航的两种不同构建方法
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(25):smp.h
- 开始写博客了
- ASP.NET AJAX入门系列(1):概述
- MPI
- 4.5 客户端设计
- 解码 XML 和 DTD
- [转]修炼一名软件工程师的职业水准
- JAVA版 Http代理服务器