Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Less css, nested attributes, :hover::after

Tags:

css

nested

less

Is it possible to do this with less?

a {
    &:after {
        background: red;
    }
    &:hover {
        &:after {
            background: blue;
        }
    }
}

I can't get the :after to change color when hovering over a?

like image 903
Philip Avatar asked May 28 '13 16:05

Philip


1 Answers

The following works fine for me:

a {
    &:after {
        content:'a';
        background: red;
    }
    &:hover {
        &:after {
            background: blue;
        }
    }
}

My LESS-enabled editor, compiled that to:

a:after {
  content: 'a';
  background: red;
}
a:hover:after {
  background: blue;
}

Which does work.

like image 193
Robert McKee Avatar answered Dec 03 '22 09:12

Robert McKee