Skip to content

Instantly share code, notes, and snippets.

@silo
Last active February 28, 2017 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silo/590f85c0ec90ef03ee37361424a025b4 to your computer and use it in GitHub Desktop.
Save silo/590f85c0ec90ef03ee37361424a025b4 to your computer and use it in GitHub Desktop.
CSS: get previous sibling
<a href="#">test</a>
<a href="#" class="active">test</a>
<a href="#">test</a>
<p>
test
</p>
<img class="image" src="http://placehold.it/350x150">
<style>
a:not(.active) { background:red }
a.active + a { background:yellow }
p:not(.image) { color: red; }
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment