Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更少的css,嵌套属性,:hover::after_Css_Nested_Less - Fatal编程技术网

更少的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;
}