要素毎に順番で背景色変更

CSS擬似

 状態:-  閲覧数:2,196  投稿日:2017-11-16  更新日:2017-12-27
テーブル
<style>
tr:nth-child(5n+1){
background-color: #ffebee;
border-bottom: 1px solid #f44336;
}
tr:nth-child(5n+2){
background-color: #E3F2FD;
border-bottom: 1px solid #2196F3;
}
tr:nth-child(5n+3){
background-color: #E8F5E9;
border-bottom: 1px solid #4CAF50;
}
tr:nth-child(5n+4){
background-color: #FFF3E0;
border-bottom: 1px solid #FF9800;
}
tr:nth-child(5n){
background-color: #F5F5F5;
border-bottom: 1px solid #9E9E9E;
}
</style>


リスト
<style>
li:nth-child(5n+1){
background-color: #ffebee;
border-bottom: 1px solid #f44336;
}
li:nth-child(5n+2){
background-color: #E3F2FD;
border-bottom: 1px solid #2196F3;
}
li:nth-child(5n+3){
background-color: #E8F5E9;
border-bottom: 1px solid #4CAF50;
}
li:nth-child(5n+4){
background-color: #FFF3E0;
border-bottom: 1px solid #FF9800;
}
li:nth-child(5n){
background-color: #F5F5F5;
border-bottom: 1px solid #9E9E9E;
}
</style>



擬似要素(Pseudo-elements)

指定要素の(内容で)2番目以降最後まで。要素:nth-of-type(n+2)



週間人気ページランキング / 6-22 → 6-28
順位 ページタイトル抜粋 アクセス数
1 キャラクター無料作成ジェネレーター / FLASH / オンラインサービス | イラスト参考(デザイン) 9
2 「属性」「プロパティ」「アトリビュート」の違い | CSS 8
3 スキップリンク | アクセシビリティ(UI) 6
4 Design 0 5
4 #2196F3の互換性 | 色変換(色) 5
5 Windows10で「Google Chrome」が常に最前面に表示される。「アクティブウィンドウ」が最前面で表示されない → 解決方法存在しない | Google Chrome(ブラウザ) 4
5 お使いのコンピュータ ネットワークから通常と異なるトラフィックが検出されました | Google Chrome(ブラウザ) 4
5 「bgcolor」「background-color」「background」の違い | CSS 4
6 RGB各成分が最大値となるのは? 3
6 SeaMonkey 2.7.2 3
6 カラーコード(色) カテゴリー 3
6 コンソールエラー / ブラウザ間差異 | ブラウザ 3
6 Illustrator CS3(Illustrator) カテゴリー 3
6 Google マップ カテゴリー 3
6 HTMLエディタ カテゴリー 3
6 ブラウザ カテゴリー 3
6 Illustrator CS2 でファイル名に「更新済み」を追加しない | Illustrator CS2(Illustrator) 3
6 「東京都」のカラーコード取得は難しい | カラーコード(色) 3
6 CSSキーフレームアニメーションで、マウスアウト時に独自のアニメーションを設定することは出来ない | アニメーション 3
6 アイコンを「Font Awesome」から変更。→「自分で探したSVG」を「自分のserver」へアップロード | アイコン(デザイン) 3
2026/6/29 5:05 更新