Skip to content

Instantly share code, notes, and snippets.

@wietseneven
Created April 18, 2013 16:04
Show Gist options
  • Save wietseneven/5413949 to your computer and use it in GitHub Desktop.
Save wietseneven/5413949 to your computer and use it in GitHub Desktop.
CSS pseudo childs
/**
* CSS pseudo childs
*/
/* Eerste en laatste */
.first-last li:first-child {
background:red;
color:white;
}
.first-last li:last-child {
background:blue;
color:white;
}
/* Elke tweede */
.nth li:nth-child(2n) {
background:green;
}
/* Alleen eerste drie */
.nth-plus li:nth-child(-n+3) {
background:orange;
}
/* Alleen de vierde */
.nth-een li:nth-child(4) {
background:yellow;
}
html{
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
font:25px helvetica;
}
ul {
clear:both;
display:block;
overflow:hidden;
margin:50px 10px 60px;
}
li {
padding:10px;
list-style:none;
float:left;
}
<ul class="first-last">
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
</ul>
<ul class="nth">
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
</ul>
<ul class="nth-plus">
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
</ul>
<ul class="nth-een">
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
<li>Lorem</li>
</ul>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment