Sli*_*ady 9 javascript css styles reactjs jss
我想要这个使用 jss 样式。
.a{
height: 20px;
}
.b{
height: 40px;
}
.a,.b{
width: 100px;
}
Run Code Online (Sandbox Code Playgroud)
制定规则c并将类添加到两者a和b
c: {
width: '100px'
}
Run Code Online (Sandbox Code Playgroud)
制作一个对象common并将它们合并到两者a并b统治
const common = {
width: '100px',
};
a: {
height: '20px',
...common
}
b: {
height: '40px',
...common
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的办法?
扩展插件如何(默认启用)?
https://cssinjs.org/jss-plugin-extend
const styles = {
buttonColor: {
background: 'red'
},
button: {
extend: 'buttonColor',
fontSize: '20px'
}
}
Run Code Online (Sandbox Code Playgroud)
我觉得更容易解析的一个更简单的替代方案是通过用引号括起来将键设置为字符串:
'.a, .b': {
width: 100px;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4510 次 |
| 最近记录: |