Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
clip-path使ってみた
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
tatsumiakahori
February 05, 2021
Programming
280
0
Share
clip-path使ってみた
CSSのclip-pathを使って「真ん中を切り抜いたマスク」を作成したお話しです。
tatsumiakahori
February 05, 2021
More Decks by tatsumiakahori
See All by tatsumiakahori
Most Valuable Bug(?) ~インシデント未遂から得た学び~
tatsumiakahori
0
260
TSデザイン改修で得たCSS設計の学び
tatsumiakahori
0
380
リッチでいい感じなWebサイトをお金も労力もかけずに作る方法
tatsumiakahori
0
210
self introduction 2
tatsumiakahori
0
67
Self introduction-Tatsumi Akahori
tatsumiakahori
0
530
Other Decks in Programming
See All in Programming
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
140
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
1
270
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
200
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
190
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
9
5.6k
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
320
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
570
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
170
存在論的プログラミング: 時間と存在を記述する
koriym
5
860
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
220
Coding as Prompting Since 2025
ragingwind
0
790
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
190
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
160
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
260
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
We Are The Robots
honzajavorek
0
210
Mind Mapping
helmedeiros
PRO
1
150
My Coaching Mixtape
mlcsv
0
97
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
220
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.2k
Transcript
clip-path使ってみた
このマスクの部分、皆さんならどう実装しますか? 物件登録時に所在地 を指定するモーダル
選ばれたのは…
clip-pathでした。
clip-pathの基本的な使い方 clip-path: <clip-source> clip-path:[ <basic-shape> || <geometry-box> ] clip-source:URLでSVG<clipPath>要素を参照 basic-shape:CSS
Shapes仕様で定義されている基本シェイプ機能を指定(inset, circle, ellipse, poligon) geometry-box:basic-shapeと組み合わせて指定すると、basic-shapeでのリファレンスボックスのようになります。 ※具体的な指定方法は不明です。
https://bennettfeely.com/clippy/ CSS generator 『Clippy』 ① ⑩ ⑨ ② ③ ⑧
④ ⑤ ⑥ ⑦ ① ② ③ ④ ⑥ ⑦ ⑧ ⑨ ⑤ ⑩
468px 468px 1198px 30.5% 30.5% 39% 10.2% 10.2% 79.6% 588px
𝒙 𝐲
clip-path: polygon( 0% 0%, 0% 100%, 30.5% 100%, 30.5% 10.2%,
69.5% 10.2%, 69.5% 89.8%, 30.5% 89.8%, 30.5% 100%, 100% 100%, 100% 0% ); ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ① ⑩ ⑨ ② ③ ⑧ ④ ⑤ ⑥ ⑦
<div class="modal-map__mask"></div> .modal-map__mask{ position: absolute; top: 0; left: 0; background-color:
rgba(0, 0, 0, .7); width: 1198px; height: 588px; clip-path: polygon(0% 0%, 0% 100%, 30.5% 100%, 30.5% 10.2%, 69.5% 10.2%, 69.5% 89.8%, 30.5% 89.8%, 30.5% 100%, 100% 100%, 100% 0%); z-index: 9; }
できた…
と思いきや…
レスポンシブ対応ができていない …
widthを100%にすればええんや!
切り抜き部分も可変になってしまっている …
この部分 = 1198px - 100%
(1198px - 100%)の半分の値分左にずらせばええんや!
@include breakpoint-down(desktop) { left: calc((100% - 1198px) / 2); }
完成。
おまけ clip-pathでアニメーション https://jsfiddle.net/takahori/jhpd4nxm/136/