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
親に向かってなんだそのz-indexは
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
sadnessOjisan
September 18, 2018
Technology
9.4k
12
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
親に向かってなんだそのz-indexは
z-indexなんぞやを覚えてしまった不良息子をどう更生させるか、その感動秘話。
→ stack context に閉じ込めたり、portalで追い出せばいいと思う。
sadnessOjisan
September 18, 2018
More Decks by sadnessOjisan
See All by sadnessOjisan
Cloudflare Workers で Rust 選ぶ理由 is 何?
sadnessojisan
1
260
AIエージェントが動かないときの原因とその対処
sadnessojisan
2
170
React のルーター事情
sadnessojisan
1
660
PHPこそ OpenTelemetry が嬉しい
sadnessojisan
2
500
TypeScript、上達の瞬間
sadnessojisan
54
19k
フロントエンド・オブザーバビリティを支える要素技術を学ぼう
sadnessojisan
2
1k
疎通2024
sadnessojisan
5
1.7k
BasicBasic認証
sadnessojisan
5
5k
ISUCON入門以前_ISUNARABE_LT#1
sadnessojisan
21
6.8k
Other Decks in Technology
See All in Technology
10年欲しかった音楽管理アプリを、AIと一緒に作りはじめた
judau
1
200
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
390
GitHub Agentic Workflows を触ってみる
htkym
2
920
AIに書かせて、プラットフォームで縛る ― EKSプラットフォームで実践した責任境界と権限設計
elmodev09
1
1.1k
TiDBファミリーにDWHが新登場!! TiDB最新情報 / TiDB update 202609
yoshiakiyamasaki
0
190
AI感のないAWS構成図をAIエージェントに描かせたい!
sagochiko
2
500
Meet AgentCore Identity Consent Portal
hironobuiga
3
160
AWS FinOps Agent 結局何が得意なの?
siromi
0
230
SDDの運用にめげずに向き合った話
sansantech
PRO
0
110
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
18
14k
20260930_Gemma4_Hands-on
tsho
0
210
DAMOS - The Smart Cruise Control for RAM
ennael
PRO
1
110
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
550
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
The World Runs on Bad Software
bkeepers
PRO
72
12k
The agentic SEO stack - context over prompts
schlessera
0
950
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
380
Music & Morning Musume
bryan
48
7.4k
A Soul's Torment
seathinner
8
3.7k
Skip the Path - Find Your Career Trail
mkilby
1
240
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
Transcript
親に向かってなんだその z-indexは!! Yuta Ide(@oijsan) 1
Yuta Ide(@ojisan) 株式会社リクルートライフスタイル 新卒2年⽬ • React • Redux & redux-saga
• NextJS • GatsbyJS Airメイト (PC / iPad / Mobile ) 2
3
_⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈⼈_ > JSのイベントなのに, CSSのお話 <  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄ 4
今⽇、話すこと • 要素の重なり順の扱い⽅ • z-indexにまつわる怪奇現象 5
プランナー「管理テーブル作ってほしいな」 6
つくったもの 7
つくったもの 枠内スクロール スクロール固定(position: sticky) モーダルの開閉 ツールチップ z-indexを⾼く設定(スク ロールの⼀番⼿前に来る) 8
つくったもの モーダルを閉じるボタン モーダルを閉じようとすると確認ダイアログ 9
案件前のお気持ち (絶対やばい…絶対やばい…絶対崩れる…) (要素の上に要素を重ねすぎだろ、、、 別ページに分けてくれよ・・・) 10
z-index + position = 怪奇現象 11
怪奇現象 モーダルを突破して来る謎のやつ 12
13
なんで、こんなことが起きたか 14
スクロール固定(position: sticky) z-indexを⾼く設定(スクロールの⼀番⼿前に来る) 疑似コード 15
⼀番⼿前にくるのが、 z-index持ちのTable header 16
<table />&<div />「親に向かってなんだそのz-indexは!」 17
Solution • modalをopen時に、 z-index=0 • modalをopen時に、 stickyを解除 • modalに⾼いz-indexを設定 18
Solution • modalをopen時に、 z-index=0 • modalをopen時に、 stickyを解除 • modalに⾼いz-indexを設定 19
⼦供より親が強くなって解決!!! 20
おしまい 21
22
⼤きいz-indexを使うのは、 親の⽴場として⼤⼈げ無い! 23
z-indexの管理をそもそも したくない!! 24
それ、CSSの標準機能でできます 25
Stack Context 26
そもそもz-indexの数値の意味は? 27
z-indexの数値の意味 要素の重なり順 28
z-indexの数値の意味 同じstack context内での要素の重なり順 29
Stack context z-indexの効果の影響範囲 30
注:どんな要素も<html />要素が作る、 ルートコンテキストに所属する 31
header要素とモーダルは同じルートコンテキストに 所属している => z-indexの⾼い⽅が前にくる 疑似コード 32
突破していしる要素を、 新しいコンテキストで包み、 z-indexの数値が外に漏れないようにする 33
コンテキストの作り⽅ https://developer.mozilla.org/ja/docs/Web/Guide/CS S/Understanding_z_index/The_stacking_context • position: absolute or relative と z-indexを当てる
• position: sticky or fixedを当てる • opacity を1以下にする 34
opacityを設定する 35
36
position: relativeを設定する 37
疑似コード 38
39
Stack contextを上⼿に使えば、 ⼦がどんなz-indexを持っていても、 スタイルの崩れを防げる 40
⼦供がz-indexを使って、⾔うことを聞かないなら、 Stack contextに閉じ込めてやりましょう。 教訓 今⽇のコード: https://github.com/sadnessOjisan/DialogOnModalOnTooltipOnTable 41