I am using Modernizr which sets up a touch
or no-touch
class on the <html>
tag. Now I am using SASS and in a nested clause I had
li:hover {
// ...
}
I would like to apply this definition only if we have no-touch
on the html
tag.
.no-touch li:hover {
// ...
}
Doesn't work, since it's on the root. Is there a SASS shorthand or way to get what I want without creating a completely new CSS rule outside of all the definitions.
<html class="no-touch">
<body>
<div>
<!-- a lot of HTML -->
<ul>
<li> ... </li>
</ul>
<!-- /a lot of HTML -->
</div>
</body>
</html>
If I would use the &
operator like this:
&.no-touch {
li:hover {
}
It would append the no-touch
rule only to the surrounding ul
element, resulting the following generated CSS:
ul.no-touch li:hover {
}
Which doesn't cover the case, since no-touch
is defined on <html>
and not <ul>
Also taken from the SASS documentation:
& will be replaced with the parent selector as it appears in the CSS
The parent selector does not reference to the <html>
tag