This article shares the specific code of js to realize the content switching of the mouse in and out of the card for your reference. The specific content is as follows Case dynamic effect diagram: HTML code: <div class="sports-purple"> <div class="all"> <!-- Contents --> <div class="content"> <div class="first-block"> <!-- Sidebar for content --> <div class="aside"> <h2>Categories</h2> <ul class="lis"> <li class="sna"> <a href="#">Sneakers</a> <div id="sub"> <div><a href="#">Running Shoes</a></div> <div><a href="#">Basketball Shoes</a></div> <div><a href="#">Soccer Shoes</a></div> <div><a href="#">Hiking Shoes</a></div> <div><a href="#">Skateboarding Shoes</a></div> <div><a href="#">Dance shoes</a></div> <div><a href="#">Tennis Shoes</a></div> <div><a href="#">Cycling Shoes</a></div> <div><a href="#">Walking Shoes</a></div> <div><a href="#">Golf Shoes</a></div> </div> </li> <li class="sna"> <a href="#">Sports Clothing</a> <div id="sup"> <div><a href="#">Jackets</a></div> <div><a href="#">Base Layers</a></div> <div><a href="#">Shirts</a></div> <div><a href="#">Sets/Suits</a></div> </div> </li> <li class="sna"> <a href="#">Cycling</a> <div id="cyc"> <div><a href="#">Bicycle</a></div> <div><a href="#">Bicycle Parts</a></div> <div><a href="#">Bicycle Accessories</a></div> <div><a href="#">Bicycle Repair Tools</a></div> <div><a href="#">Cycling Clothings</a></div> <div><a href="#">Cycling Shoes</a></div> <div><a href="#">Electric Bicycle</a></div> <div><a href="#">Electric Bicycle Part</a></div> <div><a href="#">Self Balance Scooters</a></div> </div> </li> <li class="sna"> <a href="#">Finshing</a> <div id="fin"> <div><a href="#">Fishing Rods</a></div> <div><a href="#">Fishing Reels</a></div> <div><a href="#">Rod Combo</a></div> <div><a href="#">Fishing Lures</a></div> <div><a href="#">Fishing Lines</a></div> <div><a href="#">Fishhooks</a></div> <div><a href="#">Fishing Tackle Boxes</a></div> <div><a href="#">Fishing Float</a></div> <div><a href="#">Fishing Net</a></div> <div><a href="#">Fishing Rope</a></div> </div> </li> <li class="sna"> <a href="#">Hunting</a> <div id="hun"> <div><a href="#">Bow & Arrow</a></div> <div><a href="#">Hunting Optics</a></div> <div><a href="#">Hunting Cameras</a></div> <div><a href="#">Weapon Lights</a></div> <div><a href="#">Hunting Bags & Holsters</a></div> <div><a href="#">Hunting Knife</a></div> <div><a href="#">Hunting Lights</a></div> <div><a href="#">Hunting Decoy</a></div> <div><a href="#">Hunting Gun Accessories</a></div> <div><a href="#">Scope Mounts & Accessories</a></div> </div> </li> <li class="sna"> <a href="#">Camping & Hiking</a> <div id="cam"> <div><a href="#">Tents</a></div> <div><a href="#">Sun Shelter</a></div> <div><a href="#">Sleeping Bags</a></div> <div><a href="#">Climbing Bags</a></div> <div><a href="#">Outdoor Stoves</a></div> <div><a href="#">Outdoor Tablewares</a></div> <div><a href="#">Picnic Bags</a></div> <div><a href="#">Water Bags</a></div> <div><a href="#">Camping Mat</a></div> <div><a href="#">Outdoor Lighting</a></div> </div> </li> <li class="sna"> <a href="#">Fitness & Body Building</a> <div id="fit"> <div><a href="#">Fitness Equipments</a></div> <div><a href="#">Outdoor Fitness Equipment</a></div> <div><a href="#">Boxing</a></div> <div><a href="#">Yoga</a></div> <div><a href="#">Gymnastics</a></div> <div><a href="#">Martial Arts</a></div> <div><a href="#">Weight Lifting</a></div> <div><a href="#">Weight Lifting Gloves</a></div> <div><a href="#">Fitness Gloves</a></div> <div><a href="#">Dance shoes</a></div> </div> </li> <li class="sna"> <a href="#">Musical Instruments</a> <div id="mus"> <div><a href="#">Guitar</a></div> <div><a href="#">Guitar Parts & Accessories</a></div> <div><a href="#">Violin</a></div> <div><a href="#">Violin Parts & Accessories</a></div> <div><a href="#">Woodwind Instruments</a></div> <div><a href="#">Percussion Instruments</a></div> <div><a href="#">Instrument Bags & Cases</a></div> <div><a href="#">Brass Instruments</a></div> <div><a href="#">Keyboard Instruments</a></div> </div> </li> </ul> <div class="flip"> <a href="#"class="page pagedown"> <img src="../images/arrow.png"> </a> <a href="#"class="page pageup"> <img src="../images/arrow.png"> </a> <div class="tail"> 1/3 </div> </div> </div> </div> </div> </div> </div> </div> CSS: *{ margin:0; padding:0; } a{ text-decoration: none; } li{ list-style: none; } .sports-purple{ width: 100%; background-color: #EEEEEE; position: relative; padding-top: 10px; } /* Start of content sidebar style */ .first-block{ width: 100%; height: 500px; } .aside{ width: 280px; height: 465px; background-color: #FFFFFF; margin-left: 150px; } .aside h2{ color: #a059cb; text-align: left; line-height: 60px; border-bottom: 1px solid #A059CB; font-weight: 400; font-size: 18px; padding: 0 20px; } .lis li{ border-bottom: 1px solid #EEEEEE; line-height: 40px; height: 40px; margin: 0 20px 0 20px; } .lis li a{ color: #000000; font-size: 13px; } .list a:hover,.lis li a:hover{ color: #FF4500; text-decoration: underline; } .flip{ margin: 20px 0 20px 0px; line-height: 30px; } .flip .pagedown{ width: 30px; height: 30px; border-radius: 4px; display: inline-block; border: 1px solid #a5a5a5; position: relative; left: 20px; overflow: hidden; margin-bottom: 20px; } .flip .pagedown img{ position: absolute; left: 10px; top: 13px; } .flip .pageup{ width: 30px; height: 30px; border-radius: 4px; display: inline-block; border: 1px solid #a5a5a5; position: relative; left: 40px; overflow: hidden; margin-bottom: 20px; } .flip .pageup img{ position: absolute; left: -30px; top: -32px; } .flip .tail{ float: right; margin-right: 130px; font-size: 12px; } #sub, #sup, #cyc, #fin, #hun, #cam, #fit, #mus width: 300px; height: 403px; position: absolute; left: 400px; top: 70px; font-size: 13px; border: 1px solid #A059CB; background-color: #FFFFFF; z-index: 10; display: none; } .aside li:hover{ border-left: 4px solid #A059CB; border-top: 1px solid #A059CB; border-bottom: 1px solid #A059CB; padding-left: 10px; margin-left: 20px; background-color: #FFFFFF; } #sub div,#sup div, #cyc div,#fin div, #hun div,#cam div,#fit div, #mus div{ margin-left: 20px; } js code: // Get li according to class name var lis = document.getElementsByClassName("sna"); //Loop through the li tags with class name sna for(var i = 0;i<lis.length;i++){ //Register mouse move event for li lis[i].onmouseover = function(){ /* this: li with class name sna */ //console.log(this); /* this.children: Get the child elements under the li tag*/ // console.log(this.children); var next = this.children; //next[1]: Among the two sub-elements under li, the subscript of the label of the element to be displayed is 1 next[1].style.display = "block"; }; //Register mouse out event for li lis[i].onmouseout = function(){ var next = this.children; next[1].style.display = "none"; }; } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: An article to deal with Mysql date and time functions
>>: Docker pull image and tag operation pull | tag
1. Prepare in Advance For your convenience, I cre...
1. Sometimes we use ES Due to limited resources o...
Today, when I was configuring Tomcat to access th...
1. Download the latest nginx docker image $ docke...
I recently encountered a bug where I was trying t...
Make a note so you can come back and check it lat...
Master-slave synchronization, also called master-...
Detailed example of getting the maximum value of ...
This article will not explain the use and install...
Method 1: Use the SET PASSWORD command MySQL -u r...
Install Docker Desktop Download address: Docker D...
Preface When I was working on a project recently,...
I recently watched a video of a foreign guy using...
The basic structure of HTML hypertext documents is...
The img tag in XHTML is so-called self-closing, w...