![](/img/trans.png)
[英]How to change carousel image slider indicators(arrows) color only on the second slide?
[英]i want to remove the Carousel arrows and indicators if there is only one
<Col md={6}>
<Carousel>
{product.image ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.image}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
<Carousel.Item>
<img
className="d-block w-100"
src={product.image}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item>
}
{product.imageSecond ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.imageSecond}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
null
}
{product.imageThird ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.imageThird}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
null
}
{product.imageFourth ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.imageFourth}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
null
}
{product.imageFifth ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.imageFifth}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
null
}
{product.imageSixth ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.imageSixth}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
null
}
{product.imageSeventh ?
<Carousel.Item>
<img
className="d-block w-100"
src={product.imageSeventh}
style={{width:'540px', height:'480px'}}
/>
</Carousel.Item> :
null
}
</Carousel>
</Col>
我尝试使用 DOM 来做,但它没有工作,因为它显示 class 是未定义的。 我不太擅长 css 和 DOM
仅当有两个或更多图像时,我才希望图像具有这些箭头和底部指示器 任何帮助将不胜感激
const imagesArray = [...document.querySelectorAll('.d-block.w-100')]
if(imagesArray.length === 1){
const leftArrow = document.querySelector('.carousel-control-prev-icon')
const rightArrow = document.querySelector('.carousel-control-next-icon')
leftArrow.style.hidden = true
rightArrow.style.hidden = true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.