【发布时间】:2018-07-06 02:25:30
【问题描述】:
我需要对 ::before 和 ::after 应用一些 CSS 规则,但我不知道如何。
我尝试像这样(使用 JSX)将 内联样式 传递给我的组件:
const color: '#fff';
const style = {
'::before': { backgroundColor: color },
'::after': { backgroundColor: color },
};
<div style={ style }>
我也尝试了其他排列方式,例如 ':before'、'&::before'、before... 似乎没有任何效果。
这甚至被 React 支持吗?如果是这样,使用内联样式的正确方法是什么?
【问题讨论】:
标签: html css reactjs jsx pseudo-class