JS+CSS实现自动切换的网页滑动门菜单效果代码


Posted in Javascript onSeptember 14, 2015

本文实例讲述了JS+CSS实现自动切换的网页滑动门菜单效果代码。分享给大家供大家参考。具体如下:

这是一款支持自动切换功能的网页滑动门菜单,JS与CSS结合的技术成果,有人说它是自己会切换的网页选项卡标签面板,QQ登录后弹出的每日要闻迷你窗口中有类似效果,但是代码写法却是截然不同的,每一位作者的思路是不同的,因此您多了一份参考。

运行效果截图如下:

JS+CSS实现自动切换的网页滑动门菜单效果代码

在线演示地址如下:

具体代码如下:

<html>
<head>
<title>自动切换的网页滑动门菜单</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<style type="text/css">
<!--
html, body, ul, ol, li, p, h1, h2, h3, h4, h5, h6, form, fieldset, table, td, img {margin:0; padding:0; border:0;}
td,p,div,li,select,input,textarea {font-size:12px;}
ul {list-style-type:none; text-align:left;}
select,input {vertical-align:middle;}
body { color:#333; repeat-x;}
#wrap { width:750px; margin:0 auto; clear:both; background:#fff;}
.clearit { clear:both;}
a{ color:#039; text-decoration:underline;}
a:hover{ color:#F00; text-decoration:underline;}
.linkN a{ color:#039; text-decoration:none;}
.linkN a:hover{ color:#F00; text-decoration:underline;}
.linkfff a{ color:#fff; text-decoration:none;}
.linkfff a:hover{ color:#F00; text-decoration:underline;}
.linkAD5A00 a { color:#AD5A00; text-decoration:none;}
.linkAD5A00 a:hover { color:#f00; text-decoration:underline;}
.linkC00 a { color:#C00; text-decoration:none;}
.linkC00 a:hover { color:#C00; text-decoration:underline;}
.link666 a { color:#666; text-decoration:none;}
.link666 a:hover { color:#F00; text-decoration:underline;}
h1 { font-size:16px; font-family:simhei; font-weight:500; text-align:center; padding:5px 0 3px 0;}
h2 { font-size:14px; color:#fff; display:block; clear:both; text-align:left;}
h3 { font-size:14px; font-weight:200; no-repeat 2px 7px; border-bottom:2px solid #BBE5F1; padding:5px 0 2px 17px; margin:5px 0;}
span{ font-size:12px; font-weight:200; float:right; margin-right:5px;}
ul { margin:5px 0 0 5px; color:#039;}
li { padding:3px 0 3px 10px; no-repeat 3px 7px;}
.noStyle li { padding:3px 0; background:none;}
ul.two { margin:8px 0 0 12px;}
.two li { padding:3px 0 3px 10px; no-repeat 3px 7px; float:left; width:110px;}
.f14 li { font-size:14px; padding:1px 0 4px 10px;}
.blkT { margin-top:6px;}
.list14 { font-size:14px; line-height:23px;}
/*CSS for 共用模块 end*/
.leW { width:254px;}
.miW { padding:0 5px;}
.riW { width:140px; background:#F3F3F3;}
.riW li { padding:3px 0 3px 6px; no-repeat 0 7px;}
.cont_le { background:#EBF8FB; border:1px solid #A3D8E0; border-top:none; border-bottom:none; padding:8px 0 8px 0;}
.cont_all { background:#EBF8FB; border:1px solid #A3D8E0; border-top:none; padding:8px 0 8px 0;}
.text { padding:4px 0 8px 0; text-align:center;}
.pic { margin:8px 0; text-align:center;}
.textL { text-align:left; padding:3 0 8px 0;}
.blankT { margin-top:8px;}
.picfff { text-align:center;}
.picfff img { border:1px solid #fff; margin:5px 0;}
.partA .jdt { background:#D11C00; padding:5px 0 5px 0; text-align:left;}
.partA .cont_le p { float:left; margin:0 0 0 6px; text-align:center;}
.partA .miW .top { height:17px; no-repeat; text-align:right; padding:5px 18px 0 0; margin-top:8px;}
.partA .miW .top a { color:#C00; text-decoration:underline;}
.partA .miW .top a:hover { color:#C00; text-decoration:none;}
.partA .miW .cont { background:#FFFBEA; border:1px solid #FC6; border-top:none; padding-bottom:5px; border-bottom:none;}
.partA .miW .cont p{ line-height:19px; margin-left:15px;}
.partA .miW .cont .line { repeat-x; height:1px; font-size:0; margin:5px 15px;}
.partA .miW .top1 { height:15px; no-repeat; text-align:left; padding:4px 0 0 23px; margin-left:0; _margin-left:2px;}
.partA .miW .top1 h2 { color:#000;}
.partA .miW .cont1 { border:1px solid #FC6; border-top:none; padding:5px 0 8px 0;}
.partA .shiP { no-repeat bottom; width:120px; height:109px; border:1px solid #A0B2D8; margin:10px 0 0 9px;}
/*标签*/
.menu1Off,.menu1On,.menu2Off,.menu2On,.menu3Off,.menu3On,.menu4Off,.menu4On { height:20px; color:#039; text-align:center; background:#B2DBE1; cursor:pointer; padding-top:3px;}
.menu1On,.menu2On,.menu3On,.menu4On{ color:#C00; background:#fff; border-left:1px solid #34AEBE; border-right:1px solid #34AEBE;}
/*标签a*/
.menua1Off,.menua1On,.menua2Off,.menua2On{ height:16px; width:52px; color:#666; text-align:center; repeat-x; cursor:pointer; padding-top:3px;}
.menua1On,.menua2On{ color:#C00; font-weight:bold; repeat-x; }
.menuCont { background:#F3F3F3;}
.menuCont th { text-align:center; font-weight:200; padding:5px 0 3px 0;}
.menuCont .noBg td { background:#fff; padding:5px 0 3px 5px; border-right:1px solid #F3F3F3; }
.menuCont .noBg1 td { background:#F3F3F3; padding:5px 0 3px 5px; border-right:1px solid #FFF;}
.partA .tuKu { no-repeat; margin-left:5px; height:150px; text-align:center;}
.partA .tuKu p { float:left; margin:0 10px; _margin:0 8px;}
.partA .tuKu img { padding:5px; border:1px solid #D0D1D2; background:#fff; margin:8px 0;}
.partA .shiPyy { border:1px solid #FC6; margin-top:5px;}
.partA .shiPyy h2 { color:#C00; background:#FFEAAF; padding:5px 0 3px 5px;}
.partA .shiPyy img { vertical-align:middle;}
.adv { margin:8px 0;}
.leftW { width:605px; padding-right:5px; text-align:center;}
.leftW .leW { width:140px;}
.leftW .leW img { margin-bottom:8px;}
.leftW .leW p { text-align:left; line-height:19px; padding:0 5px; margin-top:5px;}
.leftW .leW .picText { text-align:left; line-height:19px; padding-right:5px; margin-bottom:8px;}
.leftW .leW .picText img { float:left; margin:0 7px;}
.midW { padding:5px 0 0 5px; text-align:left;}
.midW table { margin-bottom:8px;}
.midW td { line-height:19px; padding:3px 0px;}
.midW span { float:none; color:#929292;}
.midW .more span { float:right;}
.midW .cC00 { color:#C00; font-weight:bold;}
.rightW { width:140px; background:#F3F3F3;}
.rightW p { float:left; margin:5px 0 5px 8px; _margin:5px 0 5px 5px;}
.rightW .cont { text-align:left; line-height:19px; text-align:left; padding:8px 0 0 8px;}
.rightW .date { margin-top:8px;}
.rightW .date td { color:#666; padding:1px 0;}
.rightW .date td { background:#fff; padding:1px 0; color:#039;}
.rightW .date .cF60 { color:#F60; font-weight:bold;}
.rightW .fenX { margin-top:8px; margin-left:3px;}
.rightW .fenX td { padding:5px 0 2px 5px; background:#fff; text-align:left;}
.rightW .blk000 img { border:1px solid #000;}
-->
</style>
</head>
<!--把<body>改为-->
<body onLoad="change_Menu(1)">
<table width="254" cellspacing="0" class="partA">
 <tr>
 <td class="leW" valign="top" width="254">
 <!-- d --> <!-- d -->
 <!-- 舌签排行 begin -->
<script language="JavaScript" type="text/javascript">
//<![CDATA[
var cur_index=1
var num=4 //该值记录标签的个数
var settime
function GetObj(objName){
 if(document.getElementById){
 return eval('document.getElementById("' + objName + '")');
 }else if(document.layers){
 return eval("document.layers['" + objName +"']");
 }else{
 return eval('document.all.' + objName);
 }
}
function change_Menu(index){
 for(var i=1;i<=num;i++){/* 最多支持8个标签 */
 if(GetObj("con"+i)&&GetObj("m"+i)){
 GetObj("con"+i).style.display = 'none';
 GetObj("m"+i).className = "menu"+i+"Off";
 }
 }
 if(GetObj("con"+index)&&GetObj("m"+index)){
 GetObj("con"+index).style.display = 'block';
 GetObj("m"+index).className = "menu"+index+"On";
 }
 cur_index=index
 if(cur_index<num){
 cur_index++
 }
 else{
  cur_index=1
 }
 settime=setTimeout("change_Menu(cur_index)",2000)//设置延迟时间
}
function Menu(c_index){
 clearTimeout(settime)
 change_Menu(c_index)
 } 
//]]>
</script>
<table cellspacing="0" style="background:#3FA6B5; width:100%;" class="clearit">
 <tr>
 <td height="3"></td>
 </tr>
 <tr>
 <td align="center">自动切换</td>
 <td id="m1" onClick="Menu(1)" class="menu1On" title="栏目">栏目1</td>
 <td width="1"></td>
 <td id="m2" onClick="Menu(2)" class="menu2Off" title="栏目">栏目2</td>
 <td width="1"></td>
 <td id="m3" onClick="Menu(3)" class="menu3Off" title="栏目">栏目3</td>
 <td width="1"></td>
 <td id="m4" onClick="Menu(4)" class="menu4Off" title="栏目">栏目4</td>
 <td width="10"></td>
 </tr>
</table>
<div id="con1" class="cont_le picfff">
<p style="margin-left:1px;"><br><a href="#">111</a></p>
<div class="clearit"></div>
</div>
<div id="con2" style="display:none;" class="cont_le picfff">
<p style="margin-left:1px;"><br><a href="#">222</a></p>
<div class="clearit"></div>
</div>
<div id="con3" style="display:none;" class="cont_le picfff">
<p style="margin-left:1px;"><br><a href="#">333</a></p>
<div class="clearit"></div>
</div>
<div id="con4" style="display:none;" class="cont_le picfff">
<p style="margin-left:1px;"><br><a href="#">444</a></p>
<div class="clearit"></div>
</div>
</body>
</html>

希望本文所述对大家的JavaScript程序设计有所帮助。

Javascript 相关文章推荐
json的前台操作和后台操作实现代码
Jan 20 Javascript
js实现鼠标拖动图片并兼容IE/FF火狐/谷歌等主流浏览器
Jun 06 Javascript
js和jquery中循环的退出和继续下一个循环
Sep 03 Javascript
javascript判断并获取注册表中可信任站点的方法
Jun 01 Javascript
深入浅析同源策略和跨域访问
Nov 26 Javascript
jQuery+php实时获取及响应文本框输入内容的方法
May 24 Javascript
jQuery图片加载显示loading效果
Nov 04 Javascript
利用JS屏蔽页面中的Enter按键提交表单的方法
Nov 25 Javascript
关于jQuery EasyUI 中刷新Tab选项卡后一个页面变形的解决方法
Mar 02 Javascript
Angular2进阶之如何避免Dom误区
Apr 02 Javascript
JavaScript函数定义方法实例详解
Mar 05 Javascript
JavaScript的垃圾回收机制与内存管理
Aug 06 Javascript
JavaScript人脸识别技术及脸部识别JavaScript类库Tracking.js
Sep 14 #Javascript
JS实现可关闭的对联广告效果代码
Sep 14 #Javascript
详解JavaScript中的4种类型识别方法
Sep 14 #Javascript
jquery实现鼠标点击后展开列表内容的导航栏效果
Sep 14 #Javascript
IE中document.createElement的iframe无法设置属性name的解决方法
Sep 14 #Javascript
js动态生成Html元素实现Post操作(createElement)
Sep 14 #Javascript
IE9+已经不对document.createElement向下兼容的解决方法
Sep 14 #Javascript
You might like
php中HTTP_REFERER函数用法实例
2014/11/21 PHP
php判断某个方法是否存在函数function_exists (),method_exists()与is_callable()区别与用法解析
2020/04/20 PHP
解放web程序员的输入验证
2006/10/06 Javascript
理解Javascript_06_理解对象的创建过程
2010/10/15 Javascript
extjs中form与grid交互数据(record)的方法
2013/08/29 Javascript
解决js下referer兼容各大浏览器的方法
2014/11/03 Javascript
node.js中的fs.symlinkSync方法使用说明
2014/12/15 Javascript
nodejs爬虫抓取数据之编码问题
2015/07/03 NodeJs
js弹出对话框方式小结
2015/11/17 Javascript
js只执行1次的函数示例
2016/07/20 Javascript
分享JavaScript监听全部Ajax请求事件的方法
2016/08/28 Javascript
JavaScript变量作用域_动力节点Java学院整理
2017/06/27 Javascript
vue 计时器组件的实现代码
2017/09/14 Javascript
layerUI下的绑定事件实例代码
2018/08/17 Javascript
浅谈react性能优化的方法
2018/09/05 Javascript
python实现简单socket程序在两台电脑之间传输消息的方法
2015/03/13 Python
python通过colorama模块在控制台输出彩色文字的方法
2015/03/19 Python
python实现的守护进程(Daemon)用法实例
2015/06/02 Python
python 对象和json互相转换方法
2018/03/22 Python
解决Pycharm界面的子窗口不见了的问题
2019/01/17 Python
Python3 实现文件批量重命名示例代码
2019/06/03 Python
python-pyinstaller、打包后获取路径的实例
2019/06/10 Python
python 实现简单的FTP程序
2019/12/27 Python
Python脚本实现Zabbix多行日志监控过程解析
2020/08/26 Python
pytorch加载语音类自定义数据集的方法教程
2020/11/10 Python
阿里巴巴国际站:Alibaba.com
2016/07/21 全球购物
Skyscanner新西兰:全球领先的旅游搜索网站
2019/08/26 全球购物
《都江堰》教学反思
2014/02/07 职场文书
经济职业学院毕业生自荐书
2014/03/17 职场文书
房屋转让协议书范本
2014/04/11 职场文书
党性锻炼的心得体会
2014/09/03 职场文书
2014年后勤工作总结范文
2014/12/16 职场文书
家属答谢词
2015/01/05 职场文书
python实现ROA算子边缘检测算法
2021/04/05 Python
Pytest实现setup和teardown的详细使用详解
2021/04/17 Python
Vertica集成Apache Hudi重磅使用指南
2022/03/31 Servers