日期:2014-05-17  浏览次数:20666 次

CSS+DIV+JS鼠标移动不同的导航 显示不同内容



??CSS+DIV+JS导航显示

平常大部分时间都在写后台代码。很少做前台界面的设计。这次,由于公司需要。做了一些界面设计方面的东西。

?

主要是用CSS+DIV+JS实现的一个导航。就是鼠标移动到不同的导航菜单上,显示不同的内容。

?

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>简洁Tab</title>
<style type="text/css">
<!--
body,div,ul,li{
?padding:0;
?text-align:center;
}
body{
?font:12px "宋体";
?text-align:center;
?margin-top: 12px;
?margin-bottom: 12px;
}
a:link{
color:#00F;
text-decoration:none;
}
a:visited {
color: #00F;
text-decoration:none;
}
a:hover {
color: #c00;
text-decoration:underline;
}
ul{ list-style:none;}
/*选项卡1*/
#Tab1{
width:460px;
margin:0px;
padding:0px;
margin:0 auto;}
/*选项卡2*/
#Tab2{
width:576px;
margin:0px;
padding:0px;
margin:0 auto;}
/*菜单class*/
.Menubox {
width:100%;
background:url(http://www.hxcgw.com/bbs/upfile/20079299441652.gif);
height:28px;
line-height:28px;
}
.Menubox ul{
margin:0px;
padding:0px;
}
.Menubox li{
float:left;
display:block;
cursor:pointer;
width:114px;
text-align:center;
color:#949694;
font-weight:bold;
}
.Menubox li.hover{
padding:0px;
background:#fff;
width:116px;
border-left:1px solid #A8C29F;
border-top:1px solid #A8C29F;
border-right:1px solid #A8C29F;
background:url(http://www.hxcgw.com/bbs/upfile/200792994426548.gif);
color:#739242;
font-weight:bold;
height:27px;
line-height:27px;
}
.Contentbox{
clear:both;
margin-top:0px;
border:1px solid #A8C29F;
border-top:none;
height:181px;
text-align:center;
padding-top:8px;
}
.STYLE2 {font-size: 18px}
-->
</style>
<script>
<!--
/*第一种形式 第二种形式 更换显示样式*/
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
?var menu=document.getElementById(name+i);
?var con=document.getElementById("con_"+name+"_"+i);
?menu.className=i==cursel?"hover":"";
?con.style.display=i==cursel?"block":"none";
}
}
//-->
</script>
</head>
<body>
<br><br>
<div id="Tab1">
<div class="Menubox">
<ul>
?<li id="one1" onmouseover="setTab('one',1,4)" class="hover"> <img id="hide1" src="image/zhandian1.png" /> </li>

?<li id="one2" onmouseover="setTab('one',2,4)" ><img id="hide2" src="image/xianlu.png" /></li>

?<li id="one3" onmouseover="setTab('one',3,4)"><img src="image/huanc.png" name="hide3" id="hide3" /></li>
?
?<li id="one4" onmouseover="setTab('one',4,4)"> <img id = "hide4" src="image/gps.png" /></li>

</ul>
</div>


<div class="Contentbox">
?<div id="con_one_1" class="hover">
?????? <form>
???<h3>站点查询</h3><br />
??<span class="STYLE2">站点名称</span>
??<input type="text" name="text1" size="18" maxlength="20">
??</br>
??
??
??
??
??<img src="image/search.png" name="hide4" vspace="10" id = "hide4" />????????????
????????? <img src="image/重置.png" name="hide4" hspace="20" vspace="10" id = "hide4" />

??????? </form>
?</div>