本文实例讲述了JS+CSS实现自动切换的网页滑动门菜单效果代码。分享给大家供大家参考。具体如下:
这是一款支持自动切换功能的网页滑动门菜单,JS与CSS结合的技术成果,有人说它是自己会切换的网页选项卡标签面板,QQ登录后弹出的每日要闻迷你窗口中有类似效果,但是代码写法却是截然不同的,每一位作者的思路是不同的,因此您多了一份参考。
运行效果截图如下:
在线演示地址如下:
http://demo.jb51.net/js/2015/js-css-auto-cha-tab-menu-style-codes/
具体代码如下:
<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程序设计有所帮助。
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
更新日志
2024年11月29日
2024年11月29日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]