DDR爱好者之家 Design By 杰米
1.鼠标移入移出切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>tab切换</title> <style type="text/css"> * {padding: 0;margin: 0;} li {list-style: none;} .wrapper { margin: 0 auto; width: 100%; max-width: 1140px; } .tabbox { margin: 40px auto; width: 400px; height: 200px; border: 1px solid #f70; overflow: hidden; } .tabbox .tab-tit{ position: relative; height: 40px; } ul { position: absolute; left: -1px; width: 401px; height: 40px; line-height: 40px; background-color: #eaeaea; } ul li { float: left; border-left: 1px solid #f70; border-bottom: 1px solid #f70; text-align: center; width: 99px; height: 40px; overflow: hidden; } .clear {clear: both;} .select { padding-right: 1px; border-bottom: none; background-color: #fff; } a:link, a:visited { font-size: 16px; font-weight: bold; color: #888; text-decoration: none; } .select a { color: #333; } a:hover, a:active { color: #f20; font-weight: bold; } .tab-txt { width: 400px; padding: 40px; overflow: hidden; } .demo {display: none;} .tab-txt p { line-height: 40px; } </style> </head> <body> <div class="wrapper"> <div id="tabBox" class="tabbox"> <div id="tabTit" class="tab-tit"> <ul> <li class="select"><a href="javascript:;">女枪</a></li> <li><a href="javascript:;">提莫</a></li> <li><a href="javascript:;">盖伦</a></li> <li><a href="javascript:;">剑圣</a></li> </ul> </div> <!-- <div class="clear"></div> --> <div id="tabTxt" class="tab-txt"> <div class="demo" style="display: block;"> <p>我有两把枪,一把叫射,另一把叫,啊~</p> <p>你有一双迷人的眼睛,我非常喜欢!</p> </div> <div class="demo"> <p>我去前面探探路</p> <p>提莫队长正在待命!</p> </div> <div class="demo"> <p>放马过来吧,你会死的很光荣的!</p> <p>快点儿结束吧,我头有点儿转晕了……</p> </div> <div class="demo"> <p>我的剑就是你的剑。</p> <p>眼睛多,看东西才会更加清楚</p> </div> </div> </div> </div> <script type="text/javascript"> function $(id) { return typeof id === "string" "tabTit").getElementsByTagName("li"); var txts = $("tabTxt").getElementsByClassName("demo"); if(tits.length != txts.length) {return;} for(var i=0,l=tits.length; i<l; i++) { tits[i].id = i; tits[i].onmouseover = function() { for(var j=0; j<l; j++) { tits[j].className = ""; txts[j].style.display = "none"; } this.className = "select"; txts[this.id].style.display = "block"; } } } </script> </body> </html>
2.鼠标移入移出延时切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>tab切换之延时切换</title> <style type="text/css"> * {padding: 0;margin: 0;} li {list-style: none;} .wrapper { margin: 0 auto; width: 100%; max-width: 1140px; } .tabbox { margin: 40px auto; width: 400px; height: 200px; border: 1px solid #f70; overflow: hidden; } .tabbox .tab-tit{ position: relative; height: 40px; } ul { position: absolute; left: -1px; width: 401px; height: 40px; line-height: 40px; background-color: #eaeaea; } ul li { float: left; border-left: 1px solid #f70; border-bottom: 1px solid #f70; text-align: center; width: 99px; height: 40px; overflow: hidden; } .clear {clear: both;} .select { padding-right: 1px; border-bottom: none; background-color: #fff; } a:link, a:visited { font-size: 16px; font-weight: bold; color: #888; text-decoration: none; } .select a { color: #333; } a:hover, a:active { color: #f20; font-weight: bold; } .tab-txt { width: 400px; padding: 40px; overflow: hidden; } .demo {display: none;} .tab-txt p { line-height: 40px; } </style> </head> <body> <div class="wrapper"> <div id="tabBox" class="tabbox"> <div id="tabTit" class="tab-tit"> <ul> <li class="select"><a href="javascript:;">女枪</a></li> <li><a href="javascript:;">提莫</a></li> <li><a href="javascript:;">盖伦</a></li> <li><a href="javascript:;">剑圣</a></li> </ul> </div> <!-- <div class="clear"></div> --> <div id="tabTxt" class="tab-txt"> <div class="demo" style="display: block;"> <p>我有两把枪,一把叫射,另一把叫,啊~</p> <p>你有一双迷人的眼睛,我非常喜欢!</p> </div> <div class="demo"> <p>我去前面探探路</p> <p>提莫队长正在待命!</p> </div> <div class="demo"> <p>放马过来吧,你会死的很光荣的!</p> <p>快点儿结束吧,我头有点儿转晕了……</p> </div> <div class="demo"> <p>我的剑就是你的剑。</p> <p>眼睛多,看东西才会更加清楚</p> </div> </div> </div> </div> <script type="text/javascript"> function $(id) { return typeof id === "string" "tabTit").getElementsByTagName("li"); var txts = $("tabTxt").getElementsByClassName("demo"); if(tits.length != txts.length) {return;} for(var i=0,l=tits.length; i<l; i++) { tits[i].id = i; tits[i].onmouseover = function() { var that = this; if(timer) { clearTimeout(timer); timer = null; } timer = setTimeout(function() { for(var j=0; j<l; j++) { tits[j].className = ""; txts[j].style.display = "none"; } that.className = "select"; txts[that.id].style.display = "block"; },500); } } } </script> </body> </html>
3. tab自动切换,鼠标移入移出立即切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>tab切换之自动切换</title> <style type="text/css"> * {padding: 0;margin: 0;} li {list-style: none;} .wrapper { margin: 0 auto; width: 100%; max-width: 1140px; } .tabbox { margin: 40px auto; width: 400px; height: 200px; border: 1px solid #f70; overflow: hidden; } .tabbox .tab-tit{ position: relative; height: 40px; } ul { position: absolute; left: -1px; width: 401px; height: 40px; line-height: 40px; background-color: #eaeaea; } ul li { float: left; border-left: 1px solid #f70; border-bottom: 1px solid #f70; text-align: center; width: 99px; height: 40px; overflow: hidden; } .clear {clear: both;} .select { padding-right: 1px; border-bottom: none; background-color: #fff; } a:link, a:visited { font-size: 16px; font-weight: bold; color: #888; text-decoration: none; } .select a { color: #333; } a:hover, a:active { color: #f20; font-weight: bold; } .tab-txt { width: 400px; padding: 40px; overflow: hidden; } .demo {display: none;} .tab-txt p { line-height: 40px; } </style> </head> <body> <div class="wrapper"> <div id="tabBox" class="tabbox"> <div id="tabTit" class="tab-tit"> <ul> <li class="select"><a href="javascript:;">女枪</a></li> <li><a href="javascript:;">提莫</a></li> <li><a href="javascript:;">盖伦</a></li> <li><a href="javascript:;">剑圣</a></li> </ul> </div> <!-- <div class="clear"></div> --> <div id="tabTxt" class="tab-txt"> <div class="demo" style="display: block;"> <p>我有两把枪,一把叫射,另一把叫,啊~</p> <p>你有一双迷人的眼睛,我非常喜欢!</p> </div> <div class="demo"> <p>我去前面探探路</p> <p>提莫队长正在待命!</p> </div> <div class="demo"> <p>放马过来吧,你会死的很光荣的!</p> <p>快点儿结束吧,我头有点儿转晕了……</p> </div> <div class="demo"> <p>我的剑就是你的剑。</p> <p>眼睛多,看东西才会更加清楚</p> </div> </div> </div> </div> <script type="text/javascript"> function $(id) { return typeof id === "string" "tabTit").getElementsByTagName("li"); var txts = $("tabTxt").getElementsByClassName("demo"); if(tits.length != txts.length) {return;} for(var i=0,l=tits.length; i<l; i++) { tits[i].id = i; tits[i].onmouseover = function() { clearInterval(timer); styleFun(this.id); } tits[i].onmouseout = function() { timer = setInterval(autoPlay, 2000); } } //在开启定时器的同时清楚定时器并置空 if(timer) { clearInterval(timer); timer = null; } timer = setInterval(autoPlay, 2000); function autoPlay() { index++; if(index >= tits.length) { index = 0; } styleFun(index); } function styleFun(ele) { for(var j=0,m=tits.length; j<m; j++) { tits[j].className = ""; txts[j].style.display = "none"; } tits[ele].className = "select"; txts[ele].style.display = "block"; //将鼠标移入移出时的index传给autoPlay; index = ele; } } </script> </body> </html>
4. 广告栏切换实例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> * { margin: 0; padding: 0; list-style: none; } .wrap { height: 170px; width: 490px; margin: 20px auto; overflow: hidden; position: relative; margin: 100px auto; } .wrap ul { position: absolute; } .wrap ul li { height: 170px; } .wrap ol { position: absolute; right: 5px; bottom: 10px; } .wrap ol li { height: 20px; width: 20px; background: #ccc; border: solid 1px #666; margin-left: 5px; color: #000; float: left; line-height: center; text-align: center; cursor: pointer; } .wrap ol .on { background: #E97305; color: #fff; } </style> <script type="text/javascript"> window.onload = function() { var wrap = document.getElementById('wrap'), pic = document.getElementById('pic'), piclist = pic.getElementsByTagName('li'), list = document.getElementById('list').getElementsByTagName('li'), picheight = 170, index = 0, timer = null; if(piclist.length != list.length) { return; } // 定义并调用自动播放函数 if(timer) { clearInterval(timer); timer = null; } timer = setInterval(picFunc, 2000); function picFunc() { index++; if(index >= piclist.length) { index = 0; } changePic(index); } // 定义图片切换函数 function changePic(ele) { for(var j = 0, m = piclist.length; j < m; j++) { list[j].className = ""; } pic.style.top = -ele * picheight + "px"; list[ele].className = "on"; index = ele; } // 鼠标划过整个容器时停止自动播放 wrap.onmouseover = function() { clearInterval(timer); } // 鼠标离开整个容器时继续播放至下一张 wrap.onmouseout = function() { timer = setInterval(picFunc, 2000); } // 遍历所有数字导航实现划过切换至对应的图片 for(var i = 0, l = list.length; i < l; i++) { list[i].id = i; list[i].onmouseover = function() { changePic(this.id); } } } </script> </head> <body> <div class="wrap" id='wrap'> <ul id="pic"> <li><img src="/UploadFiles/2021-04-02/54111cd9000174cd04900170.jpg">以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年11月28日
2024年11月28日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓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]