gpt4 book ai didi

css - postcss 中的多层嵌套不起作用

转载 作者:行者123 更新时间:2023-11-28 03:21:41 25 4
gpt4 key购买 nike

当我使用postcss-loaderpostcss-cssnext 插件时,css-class 可以在第二个嵌套的前面生效,在第三个嵌套中不会没工作

样式.css

    .root {
background-color: #ccc;

& .header {
height: 60px;
background-color: #dcdcdc;
}

& .content {
border: 1px solid red;

& .test { /* doesn't work */
background-color: #00f;
height: 200px;
}
}
}

app.tsx

    <div className={style.root}>
<div className={style.header}>
Hello test
</div>
<div className={style.content}>
<div className={style.test}>

</div>
</div>
</div>

postcss-loader 配置

    {
loader: 'postcss-loader',
options: {
sourceMap: true,
sourceComments: true,
plugins: [
require('postcss-import')({
root: path.join(__dirname, './'),
path: [ path.join(__dirname, './src/toolkit') ]
}),
require('postcss-at-rules-variables')({
variables: makeAtRulesVariables(injectedCssVariables)
}),
require('postcss-modules-values'),
require('postcss-mixins')(),
require('postcss-each')(),
require('postcss-cssnext')({
features: {
customProperties: {
variables: injectedCssVariables
}
}
}),
require('postcss-reporter')({
clearMessages: true
})
]
}
}

最佳答案

能否请您在样式表和配置文件中进行这些更改。

style.css

.root {
background-color: #ccc;

.header {
height: 60px;
background-color: #dcdcdc;
}

.content {
border: 1px solid red;

.test { /* doesn't work */
background-color: #00f;
height: 200px;
}
}
}

postcss-loader config

{
loader: 'postcss-loader',
options: {
sourceMap: true,
sourceComments: true,
plugins: [
require('postcss-import')({
root: path.join(__dirname, './'),
path: [ path.join(__dirname, './src/toolkit') ]
}),
require('postcss-at-rules-variables')({
variables: makeAtRulesVariables(injectedCssVariables)
}),
require('postcss-mixins')(),
require('postcss-each')(),
require('postcss-cssnext')({
features: {
customProperties: {
variables: injectedCssVariables
}
}
}),
require('postcss-modules-values'),
require('postcss-reporter')({
clearMessages: true
})
]
}
}

关于css - postcss 中的多层嵌套不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45179994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com