我正在尝试定位页面上元素的after伪选择器。我正在为此项目尝试JSS,到目前为止,我一直是忠实拥护者,但对它来说还是很新的。我在用JSS选择:after时遇到麻烦。这可能是因为我认为是在阅读文档时遇到的。
这是我的标记:
<Link to="about" className={classes.link}>About</Link>
我的JSS看起来像这样:
link: { position: 'relative', fontFamily: fonts.family.primary '&:before': { content: ' ', position: 'absolute', bottom: 0, left: 50, width: '100%', height: '1rem', display: 'block', background:styles.colors.white } }
如果熟悉JSS的任何人都可以帮助您,那就太好了!
你做的是对的。除了两件事:
1)语法错误:输入后您缺少逗号 fontFamily: fonts.family.primary
fontFamily: fonts.family.primary
2)内容应为用双引号引起来的字符串,然后应将双引号引起来。因此,空内容将是content: '""',
content: '""',
因此,请尝试以下操作:
link: { position: 'relative', fontFamily: fonts.family.primary, '&:before': { content: '""', position: 'absolute', bottom: 0, left: 50, width: '100%', height: '1rem', display: 'block', background:styles.colors.white } }