更少的css,嵌套属性,:hover::after
有可能用更少的钱做到这一点吗更少的css,嵌套属性,:hover::after,css,nested,less,Css,Nested,Less,有可能用更少的钱做到这一点吗 a { &:after { background: red; } &:hover { &:after { background: blue; } } } 我无法获取:在之后,在将鼠标悬停在a上时更改颜色?以下操作对我来说很好: a { &:after { content:'a'; backg
a {
&:after {
background: red;
}
&:hover {
&:after {
background: blue;
}
}
}
我无法获取
:在
之后,在将鼠标悬停在a
上时更改颜色?以下操作对我来说很好:
a {
&:after {
content:'a';
background: red;
}
&:hover {
&:after {
background: blue;
}
}
}
我启用较少的编辑器,将其编译为:
a:after {
content: 'a';
background: red;
}
a:hover:after {
background: blue;
}
这确实有效
a {
&:after {
background: red;
}
&:hover,
&:after {
background: blue;
}
}
现在没事了:p
这对我来说也很好:-
我的终端将其编译为:-
你能显示你的html吗?这绝对有效。。。假设OP实际上首先生成了包含
内容的伪元素,这是问题中缺少的。呸,我错了,我的类中缺少了一个“;”。因此它不起作用。
a{
&:after{
background: red;
content: "Hover Text"
}
&:hover{
&:after{
background: yellow;
}
}
}
a:after {
background: red;
content: "Hover Text";
}
a:hover:after {
background: yellow;
}