


JS CSS implements sliding switching tab menu effect_javascript skills
The example in this article describes how to implement the sliding switching tab menu effect with JS CSS. Share it with everyone for your reference. The details are as follows:
This is a simple JS CSS sliding door special effect code. When the mouse slides over the menu, the secondary menu automatically switches, and the mouse does not need to be clicked. The sliding door effect is a relatively popular web menu effect, which is often used on the Internet. You can see this kind of menu. This menu has been tested under Firefox, IE8, and Chrome. The code compatibility is acceptable. You can use it to beautify the style for your own use.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-css-move-cha-tab-menu-style-codes/
The specific code is as follows:
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" lang="zh_CN" xml:lang="zh_CN"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> var $=function(a,b){ var ID = document.getElementById(a); var OBJ= (b)?ID.getElementsByTagName(b):ID; return OBJ } var n=0; var tab = function(MENU,BODY){ var l = MENU.length; for(var i=0;i<l;i++){ MENU[i].onmouseover=function(a){ return function(){ MENU[n].className="label" BODY[n].style.display = "none"; MENU[a].className="label label-selected"; BODY[a].style.display = "block"; n=a; } }(i); } } </script> <style> body{font-family: "微软雅黑","SimSun","宋体","Arial Narrow";} #header,#main,#footer{width: 1050px;background: #F1F9D9;margin: 5px auto;} #header{height: 50px;} #main{height: auto;} #footer{height: 50px;} #menu{height: 36px;padding: 2px 0 0 0;} li{list-style: none;cursor: pointer;} .category{margin: 0;height: 35px;border-bottom: 1px solid #b5e2f3;text-align: center;} .label{border: 1px solid #b5e2f3;float: left;width: 100px;height: 25px;margin: 0 3px;background: #F1FEF3;padding: 9px 0 0 0;outline: 0;-moz-border-radius: 5px 5px 0 0;} .label-selected{background: #FFF;border-bottom: 1px solid #FFF;} #linksContent{margin-top: -1;height: 600px;padding: 10px;border: 1px solid #b5e2f3;border-top: 0;background: #FFF;} .link{float: left;width: 180px;display: block;margin: 10px 0;} </style> <title>myLinks</title> </head> <body> <div id="container"> <div id="header"></div> <div id="main"> <div id="menu"> <ul class="category"> <li class="label label-selected">在线学习</li> <li class="label">运动休闲</li> <li class="label">编程社区</li> <li class="label">文化娱乐</li> <li class="label">休息项目</li> <li class="label">人际往来</li> </ul> </div> <div id="linksContent"> <div class="category-1" style="display:block;"> <ul> <li class="link"><span>html学习</span></li> <li class="link"><span>编译原理</span></li> <li class="link"><span>人工智能</span></li> <li class="link"><span>算法设计</span></li> </ul> </div> <div class="category-2" style="display:none;"> <ul> <li class="link"><span>开车</span></li> <li class="link"><span>郊游</span></li> <li class="link"><span>音乐</span></li> </ul> </div> <div class="category-2" style="display:none;"> <ul> <li class="link"><span>MSDN</span></li> <li class="link"><span>编译原理</span></li> <li class="link"><span>科幻电影</span></li> <li class="link"><span>技术文档</span></li> </ul> </div> <div class="category-2" style="display:none;"> <ul> <li class="link"><span>java学习</span></li> <li class="link"><span>html学习</span></li> <li class="link"><span>编译原理</span></li> <li class="link"><span>人工智能</span></li> <li class="link"><span>算法设计</span></li> </ul> </div> <div class="category-2" style="display:none;"> <ul> <li class="link"><span>html学习</span></li> <li class="link"><span>编译原理</span></li> <li class="link"><span>人工智能</span></li> </ul> </div> <div class="category-2" style="display:none;"> <ul> <li class="link"><span>java学习</span></li> <li class="link"><span>html学习</span></li> <li class="link"><span>算法设计</span></li> </ul> </div> </div> </div> <div id="footer"></div> </div> <script> tab($("menu","li"),$("linksContent","div")); </script> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.
