我正在尝试将css从较少的文件转换为实质的createStyles,而我无法理解它的工作原理。
我了解createstyle的基础知识,但我的子选择器无法正常工作
我想要的是能够访问CSS类missionStatusLibelle
.missionStatus {
display: flex;
align-items: center;
height: 34px;
width: 100%;
.missionStatusLibelle {
align-items: flex-start;
justify-content: flex-start;
margin-left: 10px;
font-size: 14px;
font-weight: 500;
line-height: 20px;
}
}
喜欢
<div className={styles.missionStatusLibelle}>
并将其转换为类似
const useStyles = makeStyles((theme: Theme) =>
createStyles({
missionStatus: {
display: "flex",
alignItems: "center",
height: "34px",
width: "100%",
missionStatusLibelle: {
alignItems: "flex-start",
justifyContent: "flex-start",
marginLeft: "10px",
fontSize: "14px",
fontWeight: 500,
lineHeight: "20px"
}
}
}));
但是除了使用伪选择器之外,我无法进入MissionStatusLibelle。
const styles = useStyles();
<div className={styles.missionStatusLibelle}>
答案 0 :(得分:0)
您想要以下内容:
const useStyles = makeStyles((theme: Theme) =>
createStyles({
missionStatus: {
display: "flex",
alignItems: "center",
height: "34px",
width: "100%",
"& $missionStatusLibelle": {
alignItems: "flex-start",
justifyContent: "flex-start",
marginLeft: "10px",
fontSize: "14px",
fontWeight: 500,
lineHeight: "20px"
}
},
missionStatusLibelle: {}
}
));