M
M
Maxim Ivanov2020-01-02 22:10:21
css
Maxim Ivanov, 2020-01-02 22:10:21

How to position the arrows relative to the slick slider block?

When the screen size decreases (less than 1920), the arrows start to move, as they are positioned relative to the block in which the slides are placed. I'm trying to set position: relative; for the active slide and just for the slide (any), but it is still positioned relative to the block in which all the slides are.
How to position relative to the slide?

<div class="slides">
  <div class="slide-item">
    <a class="slide-item-link" href="#"><img src="img/slider/slide-1.png" alt="Слайд"></a>
  </div>
  <div class="slide-item">
    <a class="slide-item-link" href="#"><img src="img/slider/slide-1.png" alt="Слайд"></a>
  </div>
  <div class="slide-item">
    <a class="slide-item-link" href="#"><img src="img/slider/slide-1.png" alt="Слайд"></a>
  </div>
</div>


.slide-item-link img {
  margin: 0 auto;
  max-width: 100%;
}

.slides {
  margin: 0 auto;
    max-width: 1920px;
  margin-top: 163px;
  margin-bottom: 500px;
}

.slider-arrows {
  background-color: #fff;
  cursor: pointer;
}

.slider-arrows__next {
  z-index: 1;
  position: absolute;
    bottom: 49px;
    right: 359px;
  padding: 50px;
  border-radius: 0px 7px 0px 0px;
}

.slider-arrows__prev {
  z-index: 1;
  position: absolute;
    bottom: 49px;
    right: 473px;
  padding: 50px;
  border-radius: 7px 0px 0px 0px;
}


$('.slides').slick({
  centerMode: true,
  centerPadding: '230px',
  slidesToShow: 1,
  nextArrow:
  '<img class="slider-arrows slider-arrows__next" src="img/slider/right.svg">',
  prevArrow:
  '<img class="slider-arrows slider-arrows__prev" src="img/slider/left.svg">',
  responsive: [
    {
      breakpoint: 1921,
      settings: {
        centerPadding: '230px'
      }
    },
    {
      breakpoint: 1681,
      settings: {
        centerPadding: '160px'
      }
    },
    {
      breakpoint: 1601,
      settings: {
        centerPadding: '130px'
      }
    },
    {
      breakpoint: 1441,
      settings: {
        centerPadding: '80px'
      }
    },
    {
      breakpoint: 1361,
      settings: {
      centerMode: false
      }
    },
  ]
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Steppp, 2020-01-03
@Steppp

In simple terms, do you need to fasten arrows on each slide?
if the slide is position: relative, then inside absolute, otherwise there is no way!
absolute looks for the first parent with position: relative!!!
It 's the PARENT ! Not at the same level, but as a PARENT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question