Reputation: 884
Im currently coding a responsive design and I am at the point where the navigation is to collapse for mobile.
To achieve this I have created two div
s and an ul
. The ul
contains my nav
elements while the div
s are going to display nav images for a drop down with mobile and tablet.
<div id="nav-tablet"><img></div>
<div id="nav-mobile"><img></div>
<ul></ul>
#nav-tablet:hover + div + ul {
display:inline;;
}
I've tested in and it works. I wanted to validate that it is valid CSS.
Upvotes: 3
Views: 897
Reputation: 324760
Absolutely. It's just as valid as table>tbody>tr>td
- there's no limit to the number of combinators.
Just be aware that +
can be a bit slower to process than other combinators, so don't overuse it.
Upvotes: 1
Reputation: 225115
Yes, it's completely valid. You can use as many +
s as you like. (Or
, or >
, or ~
for that matter.)
If you do just want to match any ul
after #nav-tablet:hover
, though, ~
does that nicely.
#nav-tablet:hover ~ ul
Upvotes: 4