March 3, 201412 yr Hey 2 things. Whats does the following mean? .nav-custom > li + li And secondly how can I center my nav within a div (using bootstrap) Thanks
March 3, 201412 yr http://code.tutsplus.com/tutorials/the-30-css-selectors-you-must-memorize--net-16048 <-- very useful tutorial
March 4, 201412 yr The > selector targets elements that are direct children of the parent. The + selector targets elements immediately preceded by another element, in this case an LI. So that statement says: Any LI that is a direct child of .nav-custom AND has an LI element immediately preceding it. <ul class="nav-custom"> <li></li> <!-- Direct child of .nav-custom, but not preceded by an LI --> <li></li> <!-- Direct child of .nav-custom, AND preceded by an LI - this would get styled --> <li> <ul> <li></li> <!-- Not a direct child of .nav-custom, so not affected --> <li></li> </ul> </li> </ul> The > selector is used, in this case, to target list items in the navigation menu, but NOT in the drop down menus. And the + selector may be used for something like adding a top border to the list item, but they don't want the first one to have a top border, so it must be preceded by an LI. These selectors are very useful - get to know them!
March 6, 201412 yr Yes the plus operator selects the next li. Its problably best though to use the :first-child or :nth-child(x) pseudo selector as it easier to debug. Only IE7 and above.
Create an account or sign in to comment