O
O
olya_0972019-11-12 17:57:10
Slick
olya_097, 2019-11-12 17:57:10

How to add titles to the slider near the arrows?

That is, when scrolling, the headings change
5dcac8c643724111320395.jpeg
https://codepen.io/Olya097/pen/XWWPKaq

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-11-12
@olya_097

Pseudo elements can be used:

.slider::before,
.slider::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 666;
}

.slider::before {
  left: 0;
  content: attr(data-prev);
}

.slider::after {
  right: 0;
  content: attr(data-next);
}

$sliderElement.on('init afterChange', function(e, { $slider }) {
  const $active = $slider.find('.slick-active');

  $slider.attr({
    'data-prev': `prev: ${$active.prev().text() || 'какой-то дефолтный текст'}`,
    'data-next': `next: ${$active.next().text() || 'какой-то дефолтный текст'}`,
  });
})

https://jsfiddle.net/z58bvgxr/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question