Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Created July 1, 2017 04:58
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 yano3nora/eed9498b5e9fbb3755590ecf434dd080 to your computer and use it in GitHub Desktop.
Save yano3nora/eed9498b5e9fbb3755590ecf434dd080 to your computer and use it in GitHub Desktop.
[css: Diff of nth-of-type / nth-child] Attention on old contents. #css

nth-child(n)

nth-childは子要素が何であってもカウント。

<dl>
	<dt>サンプル</dt>
	<dd>テキスト1</dd>  <!-- ここは dd:nth-child(3) -->
	<dd>テキスト2</dd>
</dl>

nth-of-type(n)

nth-of-typeは指定したタグのみカウント。

<dl>
	<dt>サンプル</dt>
	<dd>テキスト1</dd>  <!-- ここは dd:nth-of-type(2) -->
	<dd>テキスト2</dd>
</dl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment