使用global ::选择伪元素样式组件
我正在尝试将全局样式表应用于我的React项目,这将从默认的蓝色中更改突出显示的颜色。
但是,我不知道如何使用::选择伪元与样式组件。
const GlobalStyle = createGlobalStyle`
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;700&display=swap');
* {
/* border: 1px solid blue; */
}
html {
font-size: 62.5%; // sets 1rem = 10px
padding: 0;
margin: 0;
&::selection,
&::-moz-selection {
color: red;
background-color: yellow;
}
}
I'm trying to apply a global stylesheet to my React project, which will change the highlight color from the default blue.
However, I can't figure out how to use the ::selection pseudoelement with styled components.
const GlobalStyle = createGlobalStyle`
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;700&display=swap');
* {
/* border: 1px solid blue; */
}
html {
font-size: 62.5%; // sets 1rem = 10px
padding: 0;
margin: 0;
&::selection,
&::-moz-selection {
color: red;
background-color: yellow;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
弄清楚了,::选择假应该在根级别
Figured it out, the ::selection pseudoelement should be at the root level