首页 > 代码库 > jS事件之网站常用效果汇总
jS事件之网站常用效果汇总
下拉菜单
<!--简单的设置了样式,方便起见,将style和script写到同一个文档,着重练习事件基础-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin:0;
padding:0;
}
ul {
list-style: none;
}
body{
margin:20px auto;
}
.ul>li {
float: left;
width:150px;
height:35px;
line-height:35px;
background:mediumaquamarine;
position:relative;
}
#nav div{
background:bisque;
position:absolute;
left:0px;
top:35px;
width:150px;
display:none;
}
</style>
</head>
<body>
<div id="nav">
<ul class="ul">
<li onmouseover="show(‘div1‘)" onmouseout="hide(‘div1‘)">下拉菜单
<div id="div1">
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
</div>
</li>
<li onmouseover="show(‘div2‘)" onmouseout="hide(‘div2‘)">下拉菜单
<div id="div2">
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
</div>
</li>
<li onmouseover="show(‘div3‘)" onmouseout="hide(‘div3‘)">下拉菜单
<div id="div3">
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
</div>
</li>
<li onmouseover="show(‘div4‘)" onmouseout="hide(‘div4‘)">下拉菜单
<div id="div4">
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
<p>下拉菜单</p>
</div>
</li>
</ul>
</div>
<script>