Css下拉菜单设置

<style type="text/css">

*{margin:0px;padding:0px;}设置所有标签属性《初始化页面属性》

#nav{background-color:#eee;width:600px;height:40px;margin:0 auto;}

ui{list-style:none;} 去掉ul的默认样式

ui li{

float:left;左浮动

line-height:40px;垂直居中

text-align:center;水平居中

position:relative;//相对定位

}

a标签是行内元素

a{

text-decoration:none;取消下划线

color:#000;

display:block;变成块元素

width:90px;

padding:0 10px;自动适应

}

a:hover{

color:#fff;

background-color:#666;

}

ul li ul li{

float:none;//去掉浮动

border-left:none;

margin-top:2px;

background-color#eee;

}

ui li ul{

width:90px;

position:absolute;//绝对定位要配合top letf使用以浏览器来定位

left:0px;top:40px;

display:none;//隐藏

}

ul li :hover ul{display:block;//显示

}

</style>

<div >

<ul>

<li>首页</li>

<li>课程大厅

<ul>

<li>二级菜单</li>

</ul>

</li>

<li>学习中心</li>

<li>经典案例</li>

</ul>

<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=utf-8" />

<title>无标题文档</title>

<style type="text/css">

*{ margin:0px; padding:0px;}

#menu{ background-color:#eee; width:600px; height:40px; margin:0 auto;}

ul{ list-style:none;}

ul li{ line-height:40px; text-align:center; position:relative; float:left; }

a{ text-decoration:none; color:#000; display:block; width:90px;}

a:hover{ color:#FFF; background-color:#666;}

ul li ul li{ float:none;margin-top:2px; background-color:#eee; }

ul li ul{width:90px; position:absolute; display:none; }

ul li:hover ul{ display:block;}

</style>

</head>

<body>

<div >关于我们</a></li>

</ul>

</div>

</body>

</html>