Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
詳細度調整擬似クラスの使い所を考えてみた
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Sho Ezawa
October 03, 2019
Programming
1.2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
詳細度調整擬似クラスの使い所を考えてみた
Meguro.css #7 @ ラクスル での登壇資料
https://megurocss.connpass.com/event/145780/
Sho Ezawa
October 03, 2019
More Decks by Sho Ezawa
See All by Sho Ezawa
Rails 7.1 の新機能が使いたくて調べてみた
glico800
1
480
デザインエンジニア?を模索している話
glico800
1
90
なぜスタートアップで部活をやるのか
glico800
1
510
Figmaで作る動くペーパープロトタイプ
glico800
0
800
弱いパスワードの作り方
glico800
1
210
Other Decks in Programming
See All in Programming
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
200
dotNET_vulnclicker_intro.pdf
deka_morita
0
130
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
470
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
contenteditable と日本語入力に向き合う
colorful12
0
180
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
220
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
260
Jetpack Compose Mechanisms
skydoves
2
660
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
690
AWSに止められる覚悟してますか?
morizo_1984
2
520
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
790
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
440
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
350
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
Joys of Absence: A Defence of Solitary Play
codingconduct
1
540
Transcript
詳細度調整疑似クラスの使い所を 考えてみた Presented By @glico800
自己紹介 glico Sho Ezawa ( ) / @glico800 ビザスクlite の
Webエンジニア フロントエンドやUIデザインが好き 妻・リクガメ・シマリスの4人家族 ?
もくじ 1. 注意事項 2. 詳細度調整疑似クラスとは 3. 使い所を考えてみた 4. まとめ
1. 注意事項
注意事項 Working Draft 今後仕様の変更や採用の見送りがある可能性 があります。 詳細度調整疑似クラスは、2019/10/01 時点では W3C 勧告プロセスにおける の段階で
あり、 予めご了承ください。
2. 詳細度調整擬似クラスとは
詳細度調整疑似クラス :where() 詳細度の計算時に無視 - 引数として与えたセレクタを する疑似クラス - 英語では “The Specificity-adjustment
Psudo-class” - 2019/10/01 時点で W3C 勧告プロセスにおける Working Draft の状態
サンプル * Specificity is calculated by https://specificity.keegan.st
3. 使い所を考えてみた
どうしてわざわざ使い所を考えてみたのか 乱用すると保守性が下がりそう 擬似クラスを使うセレ クタ ちゃんと使 えば便利そう - 悪名高い !important と同様に詳細度に干渉するの
で、 - とはいえ、:hover のような はどうしても詳細度が高くなるため、 “!important” war
公式サンプルの解説 - リンクの文字装飾なし、ホバー時は下線 - ナビゲーション上のリンクだけ非マウスホバー時でも下線を付けたい。 参考: https://www.w3.org/TR/selectors-4/#zero-matches
:where() を使わなくても実現できる - リンクの文字装飾なし、ホバー時は下線 - ナビゲーション上のリンクだけ非マウスホバー時でも下線を付けたい。 参考: https://www.w3.org/TR/selectors-4/#zero-matches
もう少し実用的な例はないか…
詳細度が高くなりがちなケース :hover, :checked, :required, :first-child, ... input[type=”radio”], a[target=”_blank”] , ...
input[type=”radio”]:checked, a[target=”_blank”]:visited, ... - 擬似クラスを使うケース - 属性セレクタを使うケース - 上記を両方使うケース
ラジオボタンのスタイル例 - クラスセレクタやクラスセレクタ+擬似クラスだと 詳細度が負けてしまう 詳細度 : 0.1.0 詳細度 : 0.2.1
:where() を使うと >> クラスセレクタだけでも詳細度が勝てる! << 詳細度 : 0.0.1 詳細度 :
0.1.0
まとめ
まとめ セレクタの詳細度を無視できる 乱用には注意 詳細度が高くなりがちなスタイル >> 用途を限定して使うのが良さそう! << - 詳細度調整擬似クラス :where()
を使うと引数に与 えた - 詳細度に干渉するため - 擬似クラスや属性セレクタなどを使ったセレクタの で使うと良さそう
ご清聴ありがとうございました