Created
August 21, 2014 23:13
-
-
Save GaryJones/635b1aaea8a45f6c8833 to your computer and use it in GitHub Desktop.
Can this SCSS be optimised to avoid the position static / left auto / opacity 1 duplication?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.genesis-nav-menu { | |
// ... other styles | |
.menu-item:hover, | |
.menu-item-hover { | |
position: static; | |
> .sub-menu { // Note the > | |
left: auto; | |
opacity: 1; | |
} | |
} | |
.menu-item > a:focus { | |
position: static; | |
+ .sub-menu { // Note the + | |
left: auto; | |
opacity: 1; | |
} | |
} | |
} |
Something like this, maybe?
.genesis-nav-menu {
// ...
.menu-item {
&:hover,
&-hover {
position: static;
& > .sub-menu {
left: auto;
opacity: 1;
}
}
& > a:focus {
@extend .menu-item-hover;
& + .sub-menu {
@extend .sub-menu;
}
}
}
}
Requires Sass ~> 4.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Mike. I guess my mindset was stuck in de-duplicating the first part of the selectors as well.