2 回答

TA贡献1744条经验 获得超4个赞
我也偶然发现了这个问题。我通常会尽量避免使用!important,所以我想我会分享一个解决方案。
const CustomSlider = withStyles({
root: {
color: '#52af77',
height: 8,
'&$vertical': {
width: 8
}
},
thumb: {
height: 24,
width: 24,
backgroundColor: '#fff',
border: '2px solid currentColor',
marginTop: -8,
marginLeft: -12,
'&:focus, &:hover': {
boxShadow: '0px 0px 0px 8px rgba(84, 199, 97, 0.16)'
},
'&$active': {
boxShadow: '0px 0px 0px 12px rgba(84, 199, 97, 0.16)'
}
},
active: {},
valueLabel: {
left: 'calc(-50% + 4px)'
},
track: {
height: 8,
borderRadius: 4
},
rail: {
height: 8,
borderRadius: 4
},
vertical: {
'& $rail': {
width: 8
},
'& $track': {
width: 8
},
'& $thumb': {
marginLeft: -8,
marginBottom: -11
}
}
})(Slider)

TA贡献1725条经验 获得超8个赞
由于 materialUI 会覆盖 css,因此您可以使用!important自己的 css 来确定优先级。因此,将其添加到您的 jss/css 中:width: "14px !important",
https://codesandbox.io/s/material-demo-782cp?fontsize=14&hidenavigation=1&theme=dark
rail: {
height: 24,
width: "14px !important",
borderRadius: 24,
opacity: 1,
}
添加回答
举报