I used react-slick and made a carousel using Slider component. The code is bellow,
const carousel = (props) => {
return (
<div style={{ height: '50%', marginTop: '20px' }}>
<Slider {...settings}>
<div className={text__bar}>
<div >
<font>Lorum Ipsum 1</font>
</div>
<div className={slide1} />
</div>
<div className={text__bar}>
<div>
<font>Lorum Ipsum 2</font>
</div>
<div className={slide1} />
</div>
<div className={text__bar}>
<div>
<font>Lorum Ipsum 3</font>
</div>
<div className={slide1} />
</div>
</Slider>
<div className={purple__bar}></div>
</div>
);
};
And the settings object,
const settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 5000,
className: SlickMain,
dotsClass: button__bar,
arrows: false,
};
I have added some extra CSS to style my carousel dots (buttons) to look like bellow,
When examined by the developer tools the button related to the currently shown slide gets a CSS class injected named 'slick-active'
What I need to do is change the background color of the button corresponding to the slide, to black relapsing the current color purple.
What I did was,
.button__bar li.slick-active button {
opacity: .75;
color: #000
}
But it won't work. What am I missing?
.button__bar is the dotsClass I have given to dots in settings object.
.button__bar li.slick-active
instead of.button__bar li.slick-active button
? Unless the button actually exists insideli
. – Morpheusbutton
is insideli
– sajithneyo:before
pseudo class, have you tried that?.button__bar li.slick-active button:before { opacity: .75; color: #000 }
– Morpheusbefore
. – sajithneyodotsClass: 'button__bar'
instead of usingbutton__bar
object here? – hankchiutw