Skip to content

Instantly share code, notes, and snippets.

@nikitaeverywhere
Created August 23, 2015 19:55
Show Gist options
  • Save nikitaeverywhere/0f9267f56bac974d408e to your computer and use it in GitHub Desktop.
Save nikitaeverywhere/0f9267f56bac974d408e to your computer and use it in GitHub Desktop.
CSS-only navigation
/*
* This CSS describes the basics of trick to make CSS-only navigation.
* This type of navigation uses #anchors to switch pages.
* In this CSS anchor #page-main as well as empty anchor (#) describes the main page.
* Valid markup for this example:
* <div class="pages">
* <div class="page"> Page content 1 </div>
* <div class="page"> Page content 2 </div>
* </div>
*/
.pages > .page, .pages > .page:target ~ #page-main { /* #1 styles for hidden page */
display: none; /* Or any other styles needed. */
}
#page-main, .pages > .page:target { /* #2 styles for selected page */
display: block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment