1.导航栏(变换菜单,多级菜单)
复习JavaScript html以及CSS
代码实现:
方法一:div方法的实现
完整代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
a{
color: #FFFF99;
text-decoration: none;
}
a:hover{
color: #FFFFFF;
text-decoration: underline;
}
#top{
padding: 10px 10px 0;
font-size: 12px;
font-weight: bold;
margin: 1px 0 0;
list-style: none;
border-bottom: 8px solid #DCE6F4;
overflow: hidden;
background-color: #33b5e5;
}
.top-nav{
float: left;
margin-right: 1px;
background-color: #333333;
position: relative;
width: 80px;
height: 20px;
text-align: center;
line-height: 20px;
}
.top-nav span{
position: absolute;
visibility: hidden;
}
.top-nav:hover span{
line-height: 20px;
background: #DDDDDD;
color: #666666;
display: block;
width: 80px;
text-align: center;
padding-top: 2px;
visibility: visible;
top:0;
left: 0;
color:#FFFFFF;
background:#DC4E1B;
}
</style>
</head>
<body>
<div id="top">
<div class="top-nav"><a href="123">首页<span class="span">Home</span></a></div>
<div class="top-nav"><a href="123">课堂大厅<span class="span">Course</span></a></div>
<div class="top-nav"><a href="123">学习中心<span class="span">Learn</span></a></div>
<div class="top-nav"><a href="123">关于我们<span class="span">About</span></a></div>
</body>
<html>
方法二:用ul li方法实现
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style type="text/css">
a{
color: #ffff99;
text-decoration: none;
}
a:hover{
color: #ffffff;
text-decoration: underline;
}
.top-nav{
padding: 10px 10px 0;
font-size: 12px;
font-weight: bold;
margin: 1px 0 0 0;
list-style: none;
border-bottom: 8px solid #dc4e18;
overflow: hidden;
background-color:#335166;
}
.top-nav li{
float: left;
margin-right: 1px;
}
.top-nav li a{
position: relative;
z-index: 0;
line-height: 20px;
text-decoration: none;
background: #cc0000;
color: #666666;
display: block;
width: 80px;
text-align: center;
}
.top-nav li a span{
position: absolute;
visibility: hidden;
}
.top-nav li a:hover span{
line-height: 20px;
text-decoration: none;
background: #dddddd;
color: #666666;
display: block;
width: 80px;
text-align: center;
padding-top: 2px;
visibility: visible;
top: 0;
left: 0;
color: #ffffff;
background: #dc4e18;
}
</style>
<body>
<div id="top">
<ul class="top-nav">
<li><a href="#">首页<span>Home</span></a><>
<li ><a href="#">大厅<span>Course</span></a><>
<li ><a href="#">学习中心<span>Learn</span></a><>
<li ><a href="#">关于我们<span>About</span></a><>
</ul>
</div>
</body>
<html>
2.JQuery基础------js框架,简单易用,代码量少。
js10行。JQuery2行就可以搞定