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
Table of contents Character Set Comparison Rules ...
What is JDK? Well, if you don't know this que...
Today, when I was writing a small program, I used...
For commercial databases, database upgrade is a h...
--1. Create a new group and user for mysql # user...
Preface: Partitioning is a table design pattern. ...
I used the dialog in closure and drew a dialog wit...
Table of contents Saltstack deploys zabbix servic...
Introduction to HTML page source code layout This...
In the previous article, we introduced: MySQL8.0....
Find the problem I recently encountered a problem...
This article is just to commemorate those CSS que...
The find command is used to search for files in a...
1. Create a new object using the Object.create() ...
This article shares the specific code of JavaScri...