无法定位:在JSS中的伪选择器之前 [英] Can't target :before Pseudo selector in JSS

查看:112
本文介绍了无法定位:在JSS中的伪选择器之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在页面上定位元素的after伪选择器。我正在为这个项目尝试JSS,到目前为止我是一个巨大的粉丝,但仍然很新。我选择了JSS之后遇到了麻烦。这是可能的,因为我认为这是在阅读文档时。

I am trying to target the after pseudo selector of an element on my page. I am trying out JSS for this project and am a huge fan so far, but still very new to it. I am having troubles selecting the :after selected with JSS. Is this possible because I thought it was when reading the docs.

这是我的标记:

<链接到=关于className = {classes.link}>关于< / Link>

和我的JSS看起来像这样:

and my JSS looks like this:

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的人可以提供帮助,那就太棒了!

if anyone who is familiar with JSS could help, that would be great!

推荐答案

你所做的是对的。除了两件事:

What you did is right. Except for 2 things:

1)语法错误:在条目 fontFamily:fonts.family.primary

1) Syntax error: You're missing a comma after the entry fontFamily: fonts.family.primary

2)内容应该是用双引号括起来的字符串,而后者应该用单引号括起来。因此,空内容将是内容:'',

2) The content should be a string enclosed in double quotes which in turn should be enclosed in single quotes. So, an empty content would be 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
    }
}

这篇关于无法定位:在JSS中的伪选择器之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆