js to achieve simple accordion effect

js to achieve simple accordion effect

This article shares the specific code of js to achieve the accordion effect for your reference. The specific content is as follows

Effect:

Implementation code:

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title></title>
  <style>
   *{
    margin:0;
    padding:0;
   }
   ul,li{
    list-style:none;
   }
   .box{
    width:1200px;
    height:260px;
    margin:50px auto 0;
    overflow: hidden;
   }
   .list{
    width:2000px;
    height:260px;
   }
   .list>li{
    width:200px;
    height:260px;
    float:left;
    background-image:url(images/1.jpg);
    background-position:center center;
    background-repeat:no-repeat;
   }
   .list>li:nth-child(2){
    background-image:url(images/2.jpg);
   }
   .list>li:nth-child(3){
    background-image:url(images/3.jpg);
   }
   .list>li:nth-child(4){
    background-image:url(images/4.jpg);
   }
   .list>li:nth-child(5){
    background-image:url(images/5.jpg);
   }
   .list>li:nth-child(6){
    background-image:url(images/6.jpg);
   }
  </style>
 </head>
 <body>
  
  <div class="box">
   <ul class="list">
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
   </ul>
  </div>
  
  <script src="js/startmove.js"></script>
  <script>
   
   var oLis = document.getElementsByClassName("list")[0].children;
   
   for(var i = 0; i < oLis.length; i++){
    oLis[i].onmouseover = function(){
     for(var j = 0; j < oLis.length; j++){
      startMove(oLis[j],{
       width:160
      },50)
     }
     startMove(this,{
      width:400
     },50)
    }
    oLis[i].onmouseout = function(){
     
     for(var j = 0; j < oLis.length; j++){
      startMove(oLis[j],{
       width:200
      },10)
     }
    }
   }
   
   
  </script>
 </body>
</html>

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:
  • Pure js to achieve accordion effect code
  • Use ReactJS to implement tab page switching, menu bar switching, accordion switching and progress bar effects
  • js to achieve a simple accordion effect
  • Accordion effect navigation menu made by native js
  • Vue.js accordion menu component development example
  • js realizes the effect of foldable and expandable accordion menu
  • Pure js to achieve accordion effect
  • JS realizes the picture accordion effect
  • Native JS to achieve vertical accordion effect
  • Html5 js to achieve accordion effect

<<:  Analysis of the process of deploying pure HTML files in Tomcat and WebLogic

>>:  Problems and solutions when installing and using VMware

Recommend

How to enable Flash in Windows Server 2016

I recently deployed and tested VMware Horizon, an...

MySQL learning database backup detailed explanation

Table of contents 1.DB,DBMS,SQL 2. Characteristic...

JavaScript single thread and asynchronous details

Table of contents 1. Task Queue 2. To explain som...

A brief introduction to bionic design in Internet web design

When it comes to bionic design, many people will t...

How to use Nginx to realize the coexistence of multiple containers in the server

background There is a Tencent Linux cloud host, o...

Implementation principle and configuration of MySql master-slave replication

Database read-write separation is an essential an...

Use crontab to run the script of executing jar program regularly in centOS6

1. Write a simple Java program public class tests...

Advanced Usage Examples of mv Command in Linux

Preface The mv command is the abbreviation of mov...

Install two MySQL5.6.35 databases under win10

Record the installation of two MySQL5.6.35 databa...

Ten useful and simple MySQL functions

function 0. Display current time Command: select ...

How to use Tencent slider verification code in Vue3+Vue-cli4 project

Introduction: Compared with traditional image ver...

Demystifying the HTML 5 Working Draft

The World Wide Web Consortium (W3C) has released a...

What to do if you forget your password in MySQL 5.7.17

1. Add skip-grant-tables to the my.ini file and r...

The difference between where and on in MySQL and when to use them

When I was writing join table queries before, I a...