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

CSS擬似

 状態:-  閲覧数:1,798  投稿日: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-30 → 7-6
順位 ページタイトル抜粋 アクセス数
1 「東京都」のカラーコード取得は難しい | カラーコード(色) 11
2 Chromeデベロッパーツールで、スマホソースコードを確認したいが、USBデバッグ機能をどうしても有効にすることが出来ない | モバイルデザイン(デザイン) 10
2 鉄道会社毎のカラーコード | カラーコード(色) 10
3 utf-8ではなく、UTF-8 | HTML 7
4 「パッケージ化されてない拡張機能を読み込む」でインストールした拡張は、chromeを「更新」すると正常動作しなくなることがあります。 | Chrome 拡張機能 6
5 RGB ⇔ Lab | 色変換(色) 5
5 カラーコード / 色コード | カラーコード(色) 5
5 金融機関ブランドカラー / コーポレートカラー | カラーコード(色) 5
6 「z-index」効果を打ち消すスタイルシートは、「z-index:auto;」 4
6 16進数カラーコード / 2進数 4
6 RGBの種類 / ビットカラー | RGB(色) 4
6 キャラクター無料作成ジェネレーター / FLASH / オンラインサービス | イラスト参考(デザイン) 4
6 効果を打ち消すスタイルシート | CSS 4
6 RGB ⇔ XYZ / CIE RGB / sRGB(D65) / sRGB(C) / Adobe RGB / NTSC RGB 4
6 RGB → 色相H … 最大値基準 × 図形 の考え方 | 色変換(色) 4
6 Flickrがサポートするライセンス 9 + 特別なライセンス 2 | 画像著作権(画像) 4
7 「文春オンライン」に掲載されている画像を「Google Chrome」ブラウザでダウンロードするためには、chrome拡張機能「Absolute Enable Right Click & Copy」を使用します。 | 画像 3
7 「マウスオーバー」「ロールオーバー」「ホバー」の違い | CSS 3
7 デザイン変更 | Webデザイン(デザイン) 3
7 Windows10で「Google Chrome」が常に最前面に表示される。「アクティブウィンドウ」が最前面で表示されない → 解決方法存在しない | Google Chrome(ブラウザ) 3
2025/7/7 1:01 更新