element UI多图片展示
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
图片展示效果如下:
【使用for循环展示图片和对应图片名称,鼠标选中图片有阴影效果,可以自动换行】
对应图片上使用鼠标点击或鼠标悬浮,图片变大,展示如下:
完整代码
<template>
<div>
<div class="position">图片展示</div>
<div class="images">
<div v-for="(item, index) in info" :key="index" class="image-middle">
<el-card shadow="hover" :body-style="{ padding: '10px' }">
//添加鼠标点击或悬浮图片放大功能
<el-popover>
<img :src="info[index].src" slot="reference" class="image"/>
<img :src="info[index].src" class="imagePreview"/>
</el-popover>
<div style="text-align:center;padding-top:12px">
<span>{{info[index].name}}</span>
</div>
</el-card>
</div>
</div>
</div>
</template>
<style scoped>
/* “Tissue Search”字体样式 */
.position {
margin-left: 15px;
font-size: 30px;
font-weight: 600;
}
/* 图片总布局,样式 */
.images{
display: flex;
margin-top: 20px;
margin-left: 21px;
margin-right: 20px;
flex-wrap: wrap;
}
/* 图片之间 */
.image-middle{
margin-right: 15px;
margin-bottom: 15px;
}
/* 单张图片样式 */
.image{
width:110px;
height: 110px;
}
</style>
<script>
export default {
data() {
return {
info:[
{
"id":1,
"name":"userHead",
"src":require("../assets/tissueImages/userHead.png") ,
},
{
"id":2,
"name":"user",
"src":require("../assets/tissueImages/user.png") ,
},
{
"id":3,
"name":"haha",
"src":require("../assets/tissueImages/haha.png") ,
},
{
"id":4,
"name":"astronaut",
"src":require("../assets/tissueImages/astronaut.png") ,
},
{
"id":5,
"name":"build",
"src":require("../assets/tissueImages/build.png") ,
},
{
"id":6,
"name":"custom",
"src":require("../assets/tissueImages/custom.png") ,
},
{
"id":7,
"name":"sea",
"src":require("../assets/tissueImages/sea.png") ,
},
{
"id":8,
"name":"tree",
"src":require("../assets/tissueImages/tree.png") ,
},
{
"id":9,
"name":"Curry",
"src":require("../assets/tissueImages/Curry.png") ,
},
{
"id":10,
"name":"panda",
"src":require("../assets/tissueImages/panda.png") ,
},
]
};
},
};
</script>
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献2条内容
所有评论(0)