用CSS滤镜巧制3D按钮式导航条

王朝html/css/js·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

平面的导航条看多了,想不想做个3D的,当然制作的方法很多,真是仁者见仁,智者见智。我试着做了个按钮式的,效果还不错,每一个菜单项看起来都是一个个的按钮,制作方法也不复杂,并且大小只有几k,算瘦小的了。你只要有点html和CSS的基础知识就够了。

下面我们开始制作:

第一步:

用Dreamweaver建立一个3x1的表格,宽度为70px,不设高度值,边框设为0,间距(cellspacing)为2。

第二步:

在上面已经建立好的表格的单元格中分别插入一个1x1的表格,高度值和宽度值均设为100%,边框和间距都设为0,并在每个表格中填上菜单名称。

代码是:

<table width="70" border="0" cellpadding="0" cellspacing="2">

<tr>

<td>

<table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">

<tr>

<td >互动学校</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">

<tr>

<td>市场专家</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">

<tr>

<td>资讯中心</td>

</tr>

</table>

第三步:

现在我们建立两个CSS样式分别取名为up和down,代码如下:

.up{

border:3 outset royalblue;color:yellow;font:12px;text-align:center;background:blue;cursor:hand

}

说明:边界为3,采用outset即突起样式,颜色为royalblue,字体颜色为黄色,字体大小为12px,居中对齐,背景颜色为blue,鼠标式样为手型。

.down{

border:3 inset royalblue;color:#33ff33;font:12px;text-align:center;background:blue;cursor:hand;position: relative; left: 1px; top: 1px

}

说明:边界样式为inset即内凹,字体颜色为#33ff33,position: relative; left: 1px; top: 1px可以产生1个像素的位移,这样按钮按下去时效果好些。

第四步:

对第二步所做的表格添加样式和行为,即在table标签后加上下列代码:

class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" onclick=window.open("http://www.ccidnet.com/school/web","_blank")

说明:在通常以及鼠标弹起和移出时采用up样式,在鼠标按下时采用down样式,链接采用onclick,不要用a,因为后者在访问后会留下难看的虚线框。

另外,你还可以再加点修饰,如CSS滤镜等,不过切忌太花哨,否则反而效果不好!

为了方便你学习,下面提供了全部的代码,你可以把它们复制到写字板,生成一个txt文件,然后把文件扩展名该成htm,就可以用IE直接打开了!

<html>

<head>

<title>3D按钮式导航条</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<style>

body{text-align:center;background:#ffffff}

.up{

border:3 outset royalblue;color:yellow;font:12px;text-align:center;background:blue;cursor:hand

}

.down{

border:3 inset royalblue;color:#33ff33;font:12px;text-align:center;background:blue;cursor:hand;position: relative; left: 1px; top: 1px; clip:rect( )

}

</style>

</head>

<body>

<table width="700" border="0" cellspacing="2" cellpadding="0">

<tr>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" onclick=window.open("http://www.ccidnet.com/news","_blank") cellpadding="0" cellspacing="0">

<tr>

<td>资讯中心</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>技术天地</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>软件特供</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>IT财经</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>市场专家</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>互动学校</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>DIY专区</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>媒体全文</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>IT罗盘</td>

</tr>

</table>

</td>

<td width="10%">

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>IT人才</td>

</tr>

</table>

</td>

</tr>

</table>

<p>&nbsp;</p>

<table width="70" border="0" cellpadding="0" cellspacing="2">

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" onClick=window.open("http://www.ccidnet.com/news","_blank") cellpadding="0" cellspacing="0">

<tr>

<td>资讯中心</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>技术天地</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>软件特供</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>IT财经</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>市场专家</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>互动学校</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>DIY专区</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>媒体全文</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>IT罗盘</td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table width="100%" border="0" height="100%" class=up onMouseDown="className='down'" onMouseUp="className='up'" onMouseOut="className='up'" cellpadding="0" cellspacing="0">

<tr>

<td>IT人才</td>

</tr>

</table>

</td>

</tr>

</table>

</body>

</html>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航