垂直导航条

先是基本的列表:
<ul>
  <li><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">News</a></li>
  <li><a href="#">Contact</a></li>
</ul>

其样式表是:
ul{
  /*因IE和Opera使用左空白控制列表缩进,而Firefox使用左填充,所以先将margin和padding设置为0*/
  margin:0;
  padding:0;
  list-style-type:none;  /*去掉列表前面的符号*/
}

要将锚显示块壮,并不是直接对列表应用样式,而是对其中包含的锚应用样式:
ul{
  /*因IE和Opera使用左空白控制列表缩进,而Firefox使用左填充,所以先将margin和padding设置为0*/
  margin:0;
  padding:0;
  list-style-type:none;  /*去掉列表前面的符号*/
}


ul a{
  display:block;
  width:100px;
  height:40px;
  line-height:40px;     /*将行高也设置为40px,是为了让文本垂直居中*/
  color:#000;
  text-decoration:none;

  }

接下来实现颜色和鼠标指向锚时的颜色变化效果:
ul a{
  display:block;
  width:100px;
  height:40px;
  line-height:40px;     /*将行高也设置为40px,是为了让文本垂直居中*/
  color:#000;
  background:#94b8e9 url(image/pixy-rollover.gif) no-repeat left center;
  text-indent:50px; 
    
/*锚文本缩进50,是为了不让文字盖子在箭头上*/
  text-decoration:none;
  }

a:hover{
  background-position:right bottom;
  color:#fff;
}


仔细看,发现顶边框和底边框形成双重实线,怎么办?采用这样的方法:
ul a{
  display:block;
  width:200px;
  height:39px;
  line-height:39px;     
  color:#000;
  background:#94b8e9 url(image/pixy-rollover.gif) no-repeat left bottom;
  text-indent:50px;
  text-decoration:none;  /*锚文本缩进50,是为了不让文字盖子在箭头上*/
  }
 
a:hover{
  background-position: right bottom;
  color:#fff;

}
虽然没有双重线,但又出现了新的问题:第一项顶部的线也没了,继续:
<ul>
  <li class="first"><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">News</a></li>
  <li><a href="#">Contact</a></li>
</ul>


.......
ul a{
  display:block;
  width:200px;
  height:39px;
  line-height:39px;   
 
  color:#000;
  background:#94b8e9 url(image/pixy-rollover.gif) no-repeat left bottom;
  text-indent:50px;
  text-decoration:none;  /*锚文本缩进50,是为了不让文字盖子在箭头上*/
  }

li.first a{
  height:40px;
  line-height:40px;
  }

.......

ContractedBlock.gif ExpandedBlockStart.gif 完整的代码
<!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=utf-8" />
<title>list_shu</title>
<style type="text/css">
<!--
ul
{
  
/*因IE和Opera使用左空白控制列表缩进,而Firefox使用左填充,所以先将margin和padding设置为0*/
  margin
:0;
  padding
:0;
  list-style-type
:none;  /*去掉列表前面的符号*/
}

ul a
{
  display
:block;
  width
:200px;
  height
:39px;
  line-height
:39px;     
  color
:#000;
  background
:#94b8e9 url(image/pixy-rollover.gif) no-repeat left bottom;
  text-indent
:50px;
  text-decoration
:none;  /*锚文本缩进50,是为了不让文字盖子在箭头上*/
  
}
  
li 
{
  display
:inline;       /*在IE中,列表上下会添加额外的空间,加上它就可以消除*/
}
  
li.first a
{
  height
:40px;
  line-height
:40px;
  
}
  
a:hover
{
  background-position
: right bottom;
  color
:#fff;
}
-->
</style>
</head>

<body>
<ul>
  
<li class="first"><href="#">Home</a></li>
  
<li><href="#">About</a></li>
  
<li><href="#">News</a></li>
  
<li><href="#">Contact</a></li>
</ul>
</body>
</html>


转载于:https://www.cnblogs.com/tograce/archive/2008/11/16/1334656.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值