如何使用scss从子css为父css设置悬停样式?
我想将hover CSS写入子元素elemeent,但当父元素悬停时。比如说: 我想要的CSS输出:如何使用scss从子css为父css设置悬停样式?,css,sass,Css,Sass,我想将hover CSS写入子元素elemeent,但当父元素悬停时。比如说: 我想要的CSS输出: .parent { background:#f8f8f8; } .parent .child { color:#000; } .parent:hover child { backgruond:#000; color:#fff; } 我在SCSS中使用的内容: .parent { background:#f8f8f8; .child {
.parent {
background:#f8f8f8;
}
.parent .child {
color:#000;
}
.parent:hover child {
backgruond:#000;
color:#fff;
}
我在SCSS中使用的内容:
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
}
不清楚你想做什么,但我想是这样的 SASS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
CSS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
用于测试工具不清楚您想做什么,但我认为是这样的 SASS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
CSS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
用于测试工具不清楚您想做什么,但我认为是这样的 SASS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
CSS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
用于测试工具不清楚您想做什么,但我认为是这样的 SASS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
CSS
.parent {
background:#f8f8f8;
.child {
color:#000;
//now I want to write css here for parent:hover. how can I do this?
}
&:hover {
background:blue;
.child {
color:green;
}
}
}
.parent {
background: #f8f8f8;
}
.parent .child {
color: #000;
}
.parent:hover {
background: blue;
}
.parent:hover .child {
color: green;
}
是否用于测试工具SCSS或更少?为什么要同时标记这两个?SCS或更少?为什么要同时标记这两个?SCS或更少?为什么要同时标记这两个?SCS或更少?为什么要将两者都标记?我只想知道是否有任何解决方案可以从子css为parent:hover-stage编写css。你举的例子就是我到目前为止一直在做的事情。但每次我都必须关闭子css并放置&:hover以应用父悬停等等。所以我觉得一定有办法。不管怎样,谢谢你的回复。我想知道是否有任何解决方案可以从子css开始为父:hover阶段编写css。你举的例子就是我到目前为止一直在做的事情。但每次我都必须关闭子css并放置&:hover以应用父悬停等等。所以我觉得一定有办法。不管怎样,谢谢你的回复。我想知道是否有任何解决方案可以从子css开始为父:hover阶段编写css。你举的例子就是我到目前为止一直在做的事情。但每次我都必须关闭子css并放置&:hover以应用父悬停等等。所以我觉得一定有办法。不管怎样,谢谢你的回复。我想知道是否有任何解决方案可以从子css开始为父:hover阶段编写css。你举的例子就是我到目前为止一直在做的事情。但每次我都必须关闭子css并放置&:hover以应用父悬停等等。所以我觉得一定有办法。不管怎样,谢谢你的回复