我正在尝试使用微软的 mergeStyles 实用程序将我的 SCSS 代码移动到 React 组件中,该实用程序是其 FluentUI 框架的一部分。我一直在弄清楚如何将“::before”指定为选择器属性。出于某种原因,mergeStyles() 自己识别了 ":hover::before" 而不是 "::before"。例如,请参见下面代码中的注释。任何帮助表示赞赏。谢谢你。
export const getClassNames = (): ISidebarClassNames => {
return mergeStyleSets({
sideNavItem: {
position: "relative",
selectors: {
":not(:last-child)": {
marginBottom: ".5rem",
},
// This works and "hover::before" does indeed triggers "scaleY(1)".
// Why then does "::before" not work on its own (see below)?
":hover::before": {
transform: "scaleY(1)",
},
// TODO: This does not work in mergeStyles() but does work if coded in SCSS.
"::before": {
content: "",
position: "absolute",
top: 0,
left: 0,
bottom: 0,
width: "3px",
backgroundColor: "red",
transform: "scaleY(0)",
}
}
}