Skip to content

Instantly share code, notes, and snippets.

@tyv
Created May 21, 2012 16:54
Show Gist options
  • Save tyv/2763259 to your computer and use it in GitHub Desktop.
Save tyv/2763259 to your computer and use it in GitHub Desktop.
E:nth-of-type(an+b)
/*
E:nth-of-type(an+b)
тоже самое, но работает только с группой E-элементов
p:nth-child(2)
это параграф && это второй элемент своего родителя
p:nth-of-type(2)
это второй параграф своего родителя
http://css-tricks.com/the-difference-between-nth-child-and-nth-of-type/
*/
.parent p:nth-child(2)
{
color: red;
}
.parent p:nth-of-type(2)
{
text-decoration: line-through;
}
<div class="parent">
<p>параграф 1</p>
<p>параграф 2</p>
</div>
<hr>
<div class="parent">
<h3>заголовок</h3>
<h4>подзаголовок</h4>
<p>параграф 1</p>
<p>параграф 2</p>
</div>
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment