Nesting CSS is a very awesome feature in the CSS-PreProcessors like LESS, SASS, Stylus etc. But SASS has Ruby as dependecy while LESS & Stylus require Node.
(嵌套CSS是CSS预处理器(如LESS,SASS,Stylus等)中一个非常棒的功能。但是SASS具有Ruby作为依赖项,而LESS和Stylus需要Node。)
Due to some restrictions I can neither use Node nor Ruby or any javascript library. (由于某些限制,我无法使用Node或Ruby或任何javascript库。)
But I require the nesting feature greatly so that I can save my time, but I can't have dependencies. (但是我非常需要嵌套功能,这样我可以节省时间,但不能有依赖关系。)
I was thinking if Vanilla Javascript can do my work. (我在想香草Javascript是否可以完成我的工作。)
I assume something like this : (我假设是这样的:)
Input :
(输入:)
body {
h1 {
color: blue;
&:hover {
color: red;
}
}
Output :
(输出:)
body h1 {
color: blue;
}
body h1:hover {
color: red;
}
So, is this possible to achieve with Vanilla Javascript ?
(那么,这可以通过Vanilla Javascript实现吗?)
( No problem with ES6 or ES6+ ) If yes please teach me how. ((ES6或ES6 +没问题)如果是,请教我如何操作。)
If no than what can I do ? (如果没有,我该怎么办?)
ask by Arcanadian Arc translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…