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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
tatsumiakahori
February 05, 2021
Programming
0
280
clip-path使ってみた
CSSのclip-pathを使って「真ん中を切り抜いたマスク」を作成したお話しです。
tatsumiakahori
February 05, 2021
Tweet
Share
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
ロボットのための工場に灯りは要らない
watany
10
2.8k
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
130
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
230
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
140
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
550
Windows on Ryzen and I
seosoft
0
280
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
830
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
140
CSC307 Lecture 15
javiergs
PRO
0
240
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
2
280
OTP を自動で入力する裏技
megabitsenmzq
0
100
CSC307 Lecture 13
javiergs
PRO
0
320
Featured
See All Featured
Marketing to machines
jonoalderson
1
5k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
150
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
200
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
Paper Plane (Part 1)
katiecoart
PRO
0
5.5k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Facilitating Awesome Meetings
lara
57
6.8k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
150
Code Review Best Practice
trishagee
74
20k
Mobile First: as difficult as doing things right
swwweet
225
10k
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/