I used Vue.js to make a nine-grid image display module, which can be clicked to zoom. The actual effect of the moduleNine-grid thumbnail effect After zooming in CodeHTML <template> <div class="SongList"> //Use v-for loop to render thumbnails <div class="covers" :style="{display:MinDisplay}"> <div class="cover" v-for="(img,index) in imgs" :key='img'><img :src="img.src" width="90%" class="min" @click="ZoomIn(index)" alt=""></div> </div> // Render the enlarged image <div class="max" :style="{display:display}"> <div @click="ZoomOut" v-for="(img,index) in imgs" :key='img' :class="[index===ShowIndex?'active':'None']" ><img :src="img.src" width="100%"></div> //Navigation map below the enlarged image <div class="small"> <div :class="[{'smallActive':index===ShowIndex},'cover-small']" v-for="(img,index) in imgs" :key='img' @click="select(index)" ><img :src="img.src" width="90%"></div> </div> </div> </div> </template> CSS <style scoped> .SongList{ width: 40%; } .covers{ display: flex; justify-content: space-between; flex-wrap: wrap; } .cover{ display: flex; justify-content: center; width: 33%; margin: 10px 0; } .min{ border-radius: 10px; cursor: zoom-in; } .max{ cursor: zoom-out; width: 100%; } .small{ display: flex; justify-content: space-between; flex-wrap: wrap; } .cover-small{ display: flex; justify-content: center; width: 10%; margin: 10px 0; opacity: 0.6; cursor: pointer; } .cover-small:hover{ opacity: 1; } .active{ display: flex; } .None{ display: none; } .smallActive{ opacity: 1; } </style> Javascript <script> export default { name: "SongList", data:function() { return { ShowIndex:0, display: 'none', MinDisplay:'flex', //When using v-for loop to render images in Vue template, you cannot directly use the local location of the image file imgs:[ {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, {"src":require('***.jpg')}, ] }; }, methods:{ ZoomIn(i){ this.display='block'; this.MinDisplay='none'; this.ShowIndex=i; }, ZoomOut(){ this.display='none'; this.MinDisplay='flex'; }, select(i){ this.ShowIndex=i; } } } 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:
|
<<: HTML table markup tutorial (41): width and height attributes of the table header WIDTH, HEIGHT
>>: How to enable Swoole Loader extension on Linux system virtual host
Everything is a file! UNIX has already said it. E...
Starting from MySQL 5.7, many security updates ha...
1. Technical points involved vite version vue3 ts...
There are two types of html tags, inline elements...
In MySQL, you can use the SQL statement rename ta...
Table of contents environment Install CentOS Conf...
1 Background Recently, some performance issues ha...
1. Update the yum source The PostgreSQL version o...
If you are looking to monitor your system interac...
Preface: The importance of database backup is sel...
My original intention was to encapsulate the $not...
Preface add_header is a directive defined in the ...
Table of contents Preface Scope 1. What is scope?...
Recently, I found a fun hover animation from the ...
React tsx generates a random verification code fo...