[英]How to make a horizontal thumbnail scrollable carausel in Vue?
I am trying to replicate this sort of a thumbnail container which is horizontal scrollable.我正在尝试复制这种可水平滚动的缩略图容器。
I have a GARMENTS
button in my Vue.js Code that returns thumbnails as follows.我的 Vue.js 代码中有一个GARMENTS
按钮,它返回缩略图如下。
I am getting my thumbnails from the firebase storage and I want the carousel to look more like the first image with the horizontal scroll.我从 firebase 存储中获取我的缩略图,我希望轮播看起来更像带有水平滚动条的第一张图像。 What should I add to make it like so?我应该添加什么来使它像这样?
Here is the code for the Buttons
Component:这是Buttons
组件的代码:
<template>
<div class="gallery-container gallery-garments hide">
<div v-for="gar in allGarments" :key="gar.id" class="gallery-item">
<img :src="getImgUrl(gar.thumbnailLink)" height="150" width="100">
<span style="display:block">{{gar.name}}</span>
</div>
</div>
<v-btn color="primary" v-on:click="toggleGallery('garments')">Garments</v-btn>
<v-btn>Templates</v-btn>
<v-btn>Download</v-btn>
<v-btn>Share</v-btn>
</template>
<script>
export default {
name: "Buttons",
data () {
return {
garments: [],
}
},
methods: {
toggleGallery(type) {
document.querySelectorAll(".gallery-container").forEach(el => {
if (!el.classList.contains(`gallery-${type}`)) {
el.classList.add("hide")
}
})
document.querySelector(`.gallery-${type}`).classList.toggle("hide")
},
getImgUrl(url){ return url; }
}
}
</script>
<style>
</style>
In your CSS, a good start would be:在你的 CSS 中,一个好的开始是:
.gallery-container {
display: flex;
flex-direction: row;
height: 200px;
overflow-x: scroll;
}
Demo:演示:
.gallery-item { display: inline-block; } .gallery-container { display: flex; flex-direction: row; height: 200px; overflow-x: scroll; }
<div class="gallery-container gallery-garments hide"> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> <div class="gallery-item"> <img src="" height="150" width="100"> <span style="display:block">Name</span> </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.