reactjs - 如何使用样式化组件更改 antd 轮播点的形状和颜色
问题描述
试图改变 antd 轮播点样式,它可以用CSS实现,但不能用styled-components实现(我的项目中不允许使用 CSS)。作为前端新手,我不知道正确的解决方案。
这是代码示例https://stackblitz.com/edit/react-opnojd-rfagtz?file=index.js
解决方案
使用 styled-component 时,样式将与 className 一起应用sc-...
。
在您的情况下,它的样式将应用于div
包含.slick-slider
.
但是,.ant-carousel
它的父级是 className。
因此,如果它包含在选择器中,则不会应用样式。
尝试这个。
const CarouselWrapper = styled(Carousel)`
> .slick-dots li button {
width: 6px;
height: 6px;
border-radius: 100%;
}
> .slick-dots li.slick-active button {
width: 7px;
height: 7px;
border-radius: 100%;
background: red;
}
`;
推荐阅读
- node.js - 如何在 azure bot 节点 v4 中创建自适应卡并继续有关特定响应的对话
- javascript - 如何从 libarchive.js 获取解压缩文件和相应路径
- vb.net - 为什么 Azure 在运行 HelloWorld 时给我一个 500 错误?
- python - 使用 ChArUco 对两个摄像头进行 OpenCV 立体校准
- maps - Bing Maps 上的叠加图钉 - 如何显示两者的元数据或以一定的缩放比例将图钉分开
- reactjs - ReactNative 我无法传递到另一个页面
- mongodb - 关于 Express-session 中间件的一般疑问
- javascript - 会话的返回路径
- python - 如何检测 URL 是否在 Chrome 中打开?
- java - webflux和reactor的正确使用方法是什么