CSS+JS实现点击文字弹出定时自动关闭的DIV层菜单
2010-01-12 14:57
1146 查看
<!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=gb2312" />
<title>CSS+JS弹出DIV层</title>
<script type="text/javascript">
var w = 0;
var h = 0;
var mout;
function emotion(){
var oMenu = document.getElementById("menu");
if(w <= 50){
oMenu.style.display = "block";
fnLarge();
}
else{
fnSmall();
}
}
function fnLarge(){
var oMenu = document.getElementById("menu");
if(w < 200){
w += 50;
h += 25;
oMenu.style.width = w+"px";
oMenu.style.height = h+"px";
window.setTimeout("fnLarge()",10);
}
}
function fnSmall(){
var oMenu = document.getElementById("menu");
if(w > 0){
w -= 50;
h -= 25;
oMenu.style.width = w+"px";
oMenu.style.height = h+"px";
window.setTimeout("fnSmall()",5);
}
else{
oMenu.style.display = "none";
}
}
</script>
<style type="text/css">
body{
text-align: center;
}
p{
cursor: pointer;
margin: 0;
padding: 0;
font-size: 24px;
display: inline;
}
div a:link, div a:visited{
color: #666;
text-decoration: none;
}
div a:hover{
color: #FF6600;
text-decoration: underline;
}
div{
border: 2px solid #666;
background: #fff;
margin: 5px auto;
overflow: hidden;
display: none;
padding: 5px 10px;
}
ul,li{
margin: 0;
padding: 0;
}
li{
list-style: none;
width:70px;
}
li.title{
font-weight: bold;
}
</style>
</head>
<body>
<p onclick="emotion();">点击这行文字试试!</p>
<div id="menu" onmouseout="javascript:mout=setTimeout('fnSmall()',2111);" onMouseOver="javascript:clearTimeout
(mout);">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80" valign="top" align="left"><ul><li class="title">ASP</li><li><a href="#" onclick="fnSmall();">新闻
</a></li><li><a href="#" onclick="fnSmall();">论坛</a></li><li><a href="#" onclick="fnSmall
();">CMS</a></li><li></li>
</ul></td>
<td width="80" valign="top" align="left"><ul><li class="title">PHP</li><li><a href="#" onclick="fnSmall();">文章
</a></li><li><a href="#" onclick="fnSmall();">聊天</a></li><li><a href="#" onclick="fnSmall();">插件
</a></li><li><a href="#" onclick="fnSmall();">企业</a></li></ul></td>
<td width="80" valign="top" align="left"><ul><li class="title">JSP</li><li><a href="#" onclick="fnSmall
();">AJAX</a></li><li><a href="#" onclick="fnSmall();">JQUERY</a></li><li><a href="#" onclick="fnSmall
();">MYSQL</a></li><li><a href="#" onclick="fnSmall();">JAVA</a></li></ul></td>
</tr>
</table>
</div>
</body>
</html>
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>CSS+JS弹出DIV层</title>
<script type="text/javascript">
var w = 0;
var h = 0;
var mout;
function emotion(){
var oMenu = document.getElementById("menu");
if(w <= 50){
oMenu.style.display = "block";
fnLarge();
}
else{
fnSmall();
}
}
function fnLarge(){
var oMenu = document.getElementById("menu");
if(w < 200){
w += 50;
h += 25;
oMenu.style.width = w+"px";
oMenu.style.height = h+"px";
window.setTimeout("fnLarge()",10);
}
}
function fnSmall(){
var oMenu = document.getElementById("menu");
if(w > 0){
w -= 50;
h -= 25;
oMenu.style.width = w+"px";
oMenu.style.height = h+"px";
window.setTimeout("fnSmall()",5);
}
else{
oMenu.style.display = "none";
}
}
</script>
<style type="text/css">
body{
text-align: center;
}
p{
cursor: pointer;
margin: 0;
padding: 0;
font-size: 24px;
display: inline;
}
div a:link, div a:visited{
color: #666;
text-decoration: none;
}
div a:hover{
color: #FF6600;
text-decoration: underline;
}
div{
border: 2px solid #666;
background: #fff;
margin: 5px auto;
overflow: hidden;
display: none;
padding: 5px 10px;
}
ul,li{
margin: 0;
padding: 0;
}
li{
list-style: none;
width:70px;
}
li.title{
font-weight: bold;
}
</style>
</head>
<body>
<p onclick="emotion();">点击这行文字试试!</p>
<div id="menu" onmouseout="javascript:mout=setTimeout('fnSmall()',2111);" onMouseOver="javascript:clearTimeout
(mout);">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80" valign="top" align="left"><ul><li class="title">ASP</li><li><a href="#" onclick="fnSmall();">新闻
</a></li><li><a href="#" onclick="fnSmall();">论坛</a></li><li><a href="#" onclick="fnSmall
();">CMS</a></li><li></li>
</ul></td>
<td width="80" valign="top" align="left"><ul><li class="title">PHP</li><li><a href="#" onclick="fnSmall();">文章
</a></li><li><a href="#" onclick="fnSmall();">聊天</a></li><li><a href="#" onclick="fnSmall();">插件
</a></li><li><a href="#" onclick="fnSmall();">企业</a></li></ul></td>
<td width="80" valign="top" align="left"><ul><li class="title">JSP</li><li><a href="#" onclick="fnSmall
();">AJAX</a></li><li><a href="#" onclick="fnSmall();">JQUERY</a></li><li><a href="#" onclick="fnSmall
();">MYSQL</a></li><li><a href="#" onclick="fnSmall();">JAVA</a></li></ul></td>
</tr>
</table>
</div>
</body>
</html>
相关文章推荐
- CSS+JS实现点击文字弹出定时自动关闭DIV层菜单的方法
- CSS+JS实现点击文字弹出定时自动关闭DIV层菜单的方法
- 点击对象弹出DIV层菜单可以定时自动关闭
- JS实现点击文字弹出一个可关闭的弹出层
- js+css实现带缓冲效果右键弹出菜单
- JS实现定时自动关闭DIV层提示框的方法
- HTML+js+css实现点击图片弹出上传文件窗口的两种思路
- CSS+JS实现的div层定位功能和自动消失
- js点击弹出div层实现可拖曳的弹窗效果
- JS+CSS实现单击后的弹出菜单代码
- js实现弹出提示,自动关闭。
- JS实现点击文字对应DIV层不停闪动效果的方法
- HTML+js+css实现点击图片弹出上传文件窗口的两种思路
- js操作css属性实现div层展开关闭效果的方法
- css+html+js实现多级下拉和弹出菜单
- 纯CSS(无JS)实现的二级弹出菜单效果代码
- JS+CSS实现自动切换的网页滑动门菜单效果代码
- js实现浏览器右下角弹出提示信息窗口,几秒后自动关闭
- Flash 弹出菜单,点击舞台其他地方,关闭菜单功能的 实现方法
- CSS实现鼠标滑过文字弹出一段说明文字无JS代码