【问题标题】:how to change the antd carousel dot shape and color with styled component如何使用样式化组件更改 antd 轮播点的形状和颜色
【发布时间】:2021-03-23 16:47:15
【问题描述】:

尝试改变antd轮播点样式,CSS可以实现,styled-components不行(我的项目不允许CSS)。作为前端的新手,我不知道正确的解决方案。

这里是代码示例https://stackblitz.com/edit/react-opnojd-rfagtz?file=index.js

提前谢谢:)

【问题讨论】:

    标签: reactjs antd styled-components


    【解决方案1】:

    当使用 styled-component 时,样式将与 className sc-... 一起应用。

    在您的情况下,其样式将应用于包含.slick-sliderdiv

    但是,.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;
      }
    `;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-25
      • 2020-10-22
      • 1970-01-01
      • 2018-08-29
      • 2019-06-21
      • 2023-03-16
      • 1970-01-01
      • 2020-08-09
      相关资源
      最近更新 更多