本文介绍了伪选择器在样式组件中是否与带有Unicode字符的CSS一样工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下样式化的组件,并且尝试添加Unicode字符 \ 00d7 作为伪选择器的内容,该伪选择器是一个十字形或闭合图标.

I have the following styled-component, and I am trying to add a unicode character \00d7 as the content for a pseudo selector, which is a cross or close icon.

但是,这似乎不像在CSS中那样起作用.当然,我可以为该关闭图标使用svg作为替代,我只是好奇是否可以通过样式组件实现?它似乎允许空白的伪选择器,例如''

However this doesn't seem to work as it would in css. Of course I can use an svg for this close icon as an alternative, I was just curious if this is possible with styled-components? It seems to allow blank pseudo selector's though e.g. ''

const Close = styled.span`
  color: pink;
  &:before {
    content: '\00d7';
  }
`

推荐答案

我认为您需要将这两个注释组合在一起:

I think you need a combination of the two comments:

content: "\\d7"

这对我有用.

这篇关于伪选择器在样式组件中是否与带有Unicode字符的CSS一样工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 10:14