Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
vue - how to make gap between flex item in Slick-carousel

This is my current Slick Carousel.
There are 4 items in a row, and I want to add margin between each item without changing current aspect-ratio: 1.3/1;

I find that I have difficulty to override the vue-slick-carousel classes. Is Anyone know how to do it?

enter image description here

HelloWorld.vue

<template>
  <div class="slick">
    <VueSlickCarousel
      v-bind="{
        arrow: true,
        focusOnSelect: true,
        speed: 500,
        slidesToShow: 4,
        slidesToScroll: 4,
        touchThreshold: 5,
      }"
    >
      <div class="slick-item">1</div>
      <div class="slick-item">2</div>
      <div class="slick-item">3</div>
      <div class="slick-item">4</div>
      <div class="slick-item">5</div>
      <div class="slick-item">6</div>
      <template #prevArrow="">
        <button class="arrow-btn">
          <img src="@/assets/images/common/arrow-right.svg" alt="arrow-left" />
        </button>
      </template>
      <template #nextArrow="">
        <button class="arrow-btn">
          <img src="@/assets/images/common/arrow-right.svg" alt="arrow-left" />
        </button>
      </template>
    </VueSlickCarousel>
  </div>
</template>

<script>
import VueSlickCarousel from "vue-slick-carousel";
import "vue-slick-carousel/dist/vue-slick-carousel.css";

export default {
  components: { VueSlickCarousel },
};
</script>

<style scoped lang="scss">
// override default class

.slick-slider {
  display: flex;
  align-items: center;
  border: 1px solid grey;
}

.slick-item {
  aspect-ratio: 1.3/1;
  max-width: 280px;
  margin-left: 10px;
  background-color: #e5e5e5;
}
.arrow-btn {
  border: none;
  img {
    height: 40px;
  }
}
</style>

Codesandbox:
https://codesandbox.io/s/empty-leftpad-ti367?file=/src/components/HelloWorld.vue

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you look at the examples on the npm package itself, spacing between slides are achieved by wrapping each slide with an additional <div> element and then adding margins to the inner one.

Your best bet is to update your DOM as such, by wrapping your .slick-item element with an additional <div>:

<div><div class="slick-item">1</div></div>

Then in your CSS it is a matter of adding an arbitrary horizontal margin, e.g. margin: 0 5px to achieve a 10px spacing between each slide:

.slick-item {
  margin: 0 5px;
  background-color: #e5e5e5;
  aspect-ratio: 1.3/1;
  max-width: 280px;
}

See proof-of-concept example: https://codesandbox.io/s/charming-bas-b78ke?file=/src/components/HelloWorld.vue

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda