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

SQL implementation of LeetCode (196. Delete duplicate mailboxes)

[LeetCode] 196.Delete Duplicate Emails Write a SQ...

MySQL date functions and date conversion and formatting functions

MySQL is a free relational database with a huge u...

MySQL 5.7.19 (tar.gz) installation graphic tutorial under Linux

The first tutorial for installing MySQL-5.7.19 ve...

Example of downloading files with vue+django

Table of contents 1. Overview 2. Django Project 3...

javascript countdown prompt box

This article example shares the specific code of ...

Vue page monitoring user preview time function implementation code

A recent business involves such a requirement tha...

Detailed installation and use of docker-compose

Docker Compose is a Docker tool for defining and ...

MySQL gets the current date and time function

Get the current date + time (date + time) functio...

How to adjust the log level of nginx in Docker

Table of contents Intro Nginx Dockerfile New conf...

A detailed introduction to Linux system operation levels

Table of contents 1. Introduction to Linux system...

Usage of Vue filters and timestamp conversion issues

Table of contents 1. Quickly recognize the concep...

JavaScript array merging case study

Method 1: var a = [1,2,3]; var b=[4,5] a = a.conc...

Detailed tutorial on using the tomcat8-maven-plugin plugin in Maven

I searched a lot of articles online but didn'...