Style a Slider Thumb with Styled Components

女生的网名这么多〃 提交于 2021-01-26 03:58:41

问题


I am trying to style a slider with styled-components for React, but I do not get how I can style the thumb. I have a CSS that looks like this:

.faderInput::-webkit-slider-thumb {
   -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border:1px solid black;
    ...
}

and my styled component looks like this

const FaderInput = styled.input`
    ...
    ::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 15px;
        height: 15px;
        border:1px solid black;
        ...
  }
`;

Does anybody know how I can port this class selector to styled-components?


回答1:


I actually got help. You have to add a & and then it looks like this:

 const FaderInput = styled.input`
 ...
 &::-webkit-slider-thumb {
     -webkit-appearance: none;
     width: 15px;
     height: 15px;
     border:1px solid black;
     ...
  }



回答2:


This is what works well for me in Chrome and Safari. For FF you have to use this FF scrollbar

   const ScrollContainer = styled.div`
    width: 100%;
    height: 500px;
    overflow-y: auto;
    position: relative;
    &::-webkit-scrollbar {
        width: 10px;
        border: 1px solid black;
    }
`;


来源:https://stackoverflow.com/questions/47921532/style-a-slider-thumb-with-styled-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!