Let me share what I'm searching for.
I've set up a carousel that displays 7 SVG icons, each identified by an id
.
To customize the appearance of the current icon, I'm using the following CSS:
.slick-current #icon-1 path {
fill: rgb(252, 238, 33);
}
The .slick-current
class belongs to the div, and the #icon-1
refers to an svg
element inside that div
.
As the carousel cycles through, I have similar CSS styles targeting the current icon with different colors. Additionally, I want to target a separate div containing a different icon and apply some CSS to it simultaneously:
For instance, if the slick-current
class has an SVG with #icon-1
, then I aim to modify the .slick-active
div containing the SVG #icon-3
. Is there a way to merge these actions together?
Below is the Carousel HTML code snippet:
<div class="col-1 slider-cat-nav" id="slider_categories">
<div>
<img class="svg cat-icons-op" id="digital_icon" src="img/icons/icon-d.svg">
</div>
<div>
<img class="svg cat-icons-op" id="inspire_icon" src="img/icons/icon-tools.svg">
</div>
<div>
<img class="svg cat-icons-op" id="perform_icon" src="img/icons/icon-search.svg">
</div>
<div>
<img class="svg cat-icons-op" id="automate_icon" src="img/icons/icon-rocket.svg">
</div>
<div>
<img class="svg cat-icons-op" id="develop_icon" src="img/icons/icon-ab.svg">
</div>
<div>
<img class="svg cat-icons-op" id="design_icon" src="img/icons/icon-tools.svg">
</div>
<div>
<img class="svg cat-icons-op" id="plan_icon" src="img/icons/icon-rocket.svg">
</div>
</div>
Slick.js script snippet:
$('.slider-cat-name').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-cat-nav',
speed: 1000,
});
$('.slider-cat-nav').slick({
slidesToShow: 5,
slidesToScroll: -1,
arrows: false,
asNavFor: '.slider-cat-name',
vertical: true,
//autoplay: true,
autoplaySpeed: 3000,
speed: 1000,
draggable: false
});
Keep in mind that classes .slick-current
, .slick-active
, and other classes are automatically added to the divs by slick.js.
The resulting layout appears as follows:
<div class="col-1 slider-cat-nav slick-initialized slick-slider slick-vertical" id="slider_categories">
<div aria-live="polite" class="slick-list" style="height: 520px;"><div class="slick-track" role="listbox" style="opacity: 1; height: 1768px; transform: translate3d(0px, -520px, 0px);">
<div class="slick-slide slick-current slick-active" data-slick-index="0" aria-hidden="false" tabindex="-1" role="option" aria-describedby="slick-slide10" style="width: 42px;">
<img class="svg cat-icons-op" id="digital_icon" src="img/icons/icon-d.svg">
</div>
<div class="slick-slide slick-active" data-slick-index="1" aria-hidden="false" tabindex="-1" role="option" aria-describedby="slick-slide11" style="width: 42px;">
<img class="svg cat-icons-op" id="inspire_icon" src="img/icons/icon-tools.svg">
</div>
<div class="slick-slide slick-active" data-slick-index="2" aria-hidden="false" tabindex="-1" role="option" aria-describedby="slick-slide12" style="width: 42px;">
<img class="svg cat-icons-op" id="perform_icon" src="img/icons/icon-search.svg">
</div>
<div class="slick-slide slick-active" data-slick-index="3" aria-hidden="false" tabindex="-1" role="option" aria-describedby="slick-slide13" style="width: 42px;">
<img class="svg cat-icons-op" id="automate_icon" src="img/icons/icon-rocket.svg">
</div>
<div class="slick-slide slick-active" data-slick-index="4" aria-hidden="false" tabindex="-1" role="option" aria-describedby="slick-slide14" style="width: 42px;">
<img class="svg cat-icons-op" id="develop_icon" src="img/icons/icon-ab.svg">
</div>
</div>
</div>