Logo
Hyunsu Blog
cross_browsing

๐Ÿ“†Published :Dec 16, 2021 โ€ข

๐Ÿ“†Updated :Dec 16, 2021 โ€ข

โ˜•๏ธ2min

border-radius ํฌ๋กœ์Šค ๋ธŒ๋ผ์šฐ์ง• ์ด์Šˆ

1. ์ด์Šˆ

ํ˜„์žฌ ๋ธ”๋กœ๊ทธ๋Š” gatsby.js๋ฅผ ์ด์šฉํ•œ ํ”„๋กœ์ ํŠธ์ž…๋‹ˆ๋‹ค.๊ฐ ํฌ์ŠคํŒ…์˜ ํ”„๋ฆฌ๋ทฐ ์„น์…˜์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ์‹ธ๋Š” wrapper ์š”์†Œ์— border-radius css ์†์„ฑ์„ ์ ์šฉํ•˜์˜€์„๋•Œ webkit์—”์ง„์„ ์‚ฌ์šฉํ•˜๋Š” safari ๋ธŒ๋ผ์šฐ์ €์—์„  ์ ์šฉ์ด ์•ˆ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

<GatsbyImage image={thumbnail} alt={post.imageAlt} css={css` border-radius: 12px; width: 150px; `} /> crossBrowsing

2. ์ด์Šˆ ์›์ธ ๋ถ„์„

์ฒ˜์Œ์—” vendor prefix ์ ์šฉ์„ ์˜์‹ฌํ–ˆ์Šต๋‹ˆ๋‹ค. css-in-js์˜ ํ•˜๋‚˜์ธ emotion์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ, emotion์€ ๋‚ด๋ถ€์ ์œผ๋กœ auto vendor prefix๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

emotion_vendor_prefix

border radius๊ฐ€ ์ ์šฉ์ด ์•ˆ๋  ๋•Œ๋Š” ์‚ฌํŒŒ๋ฆฌ์—์„œ ์ž˜ ์•Œ๋ ค์ง„ ์˜ค๋ž˜๋œ ๋ฒ„๊ทธ์ด๊ธฐ๋„ ํ•œ ์ด์Šˆ๋กœ overflow:hidden์ผ ๋•Œ border-radius๊ฐ€ ์ •์ƒ ์ ์šฉ์ด ๋˜์ง€ ์•Š๋Š”๊ฑธ๋กœ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์ด๋ฒˆ ์ƒํ™ฉ์—์„  overflow:hidden ์„ ์ ์šฉํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ inspector๋ฅผ ๋‹ค์‹œ ๋“ค์—ฌ๋‹ค ๋ณด๋ฉด GatsbyImage API ๋ฅผ ์‚ฌ์šฉ์‹œ data-gatsby-image-wrapper๋ผ๋Š” ์—˜๋ฆฌ๋จผํŠธ๊ฐ€ ์ƒ์„ฑ์ด ๋˜๊ณ  ์ด ์—˜๋ฆฌ๋จผํŠธ๋Š” overflow: hidden; ์˜ ์†์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. Screen Shot 2021-12-16 at 10 01 07 PM

3. ์—ฌ๋Ÿฌ๊ฐ€์ง€ ํ•ด๊ฒฐ๋ฒ•.. ์™œ? ์ง„์งœ ๋ฌธ์ œ์˜ ์›์ธ์„ ์ฐพ์ž.

์ด ๋ฌธ์ œ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฒ•๋“ค์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

๋ฐฉ๋ฒ• 1.

will-change: transform ์ ์šฉ

๋ฐฉ๋ฒ•2.

-webkit-mask-image: -webkit-radial-gradient(white, black);

๋ฐฉ๋ฒ• 3.
position: relative; z-index: 1;

๊ฐ„๋‹จํ•˜๊ฒŒ ํ•œ์ค„๋กœ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์—ฌ๋Ÿฌ๊ฐ€์ง€์˜ ๋ฐฉ๋ฒ• ์ค‘ ์–ด๋–ค ์ ‘๊ทผ์ด ์ตœ์ ์ผ๊นŒ? ๊ทธ๋ฆฌ๊ณ  ์™œ ์ด๋ ‡๊ฒŒ ์—ฌ๋Ÿฌ๊ฐ€์ง€์˜ ๋ฐฉ๋ฒ•๋“ค์ด ์žˆ๋Š” ๊ฒƒ์ผ๊นŒ?

์ด๋Ÿฐ ์ด์Šˆ์˜ ์›์ธ์„ ์ข€ ๋” ์•Œ์•„๋ณด๊ธฐ๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด์Šˆ์˜ ์›์ธ๋“ค์„ ์ฐพ์œผ๋Ÿฌ ์—ฌ๋Ÿฌ article๋“ค๊ณผ ๋‹ต๋ณ€๋“ค์„ ๋ณด๋ฉด stacking context ์šฉ์–ด๊ฐ€ ์–ธ๊ธ‰๋œ ๊ฑธ ๊ฐ„ํ˜น ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ง„์งœ ๋ฌธ์ œ๋Š” vendor prefix ๊ฐ€ ์•„๋‹Œ stacking context ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ๋ธŒ๋ผ์šฐ์ € ๋ Œ๋”๋ง์—”์ง„์— ๋”ฐ๋ผ ๋‹ค๋ฅด๋‹ค๋Š” ๊ฒ๋‹ˆ๋‹ค. Mozilla ๊ณต์‹ ๋ฌธ์„œ์— ๋”ฐ๋ฅด๋ฉด,

stacking context
a three-dimensional conceptualization of HTML elements along an imaginary z-axis relative to the user, who is assumed to be facing the viewport or the webpage.

ํ•ด์„์„ ํ•ด๋„ ์ž˜ ์™€๋‹ฟ์ง€๊ฐ€ ์•Š์Šต๋‹ˆ๋‹ค. ์กฐ๊ธˆ ๋” ์‰ฝ๊ฒŒ ์ดํ•ดํ•˜์ž๋ฉด, stacking context๋ฅผ ์ดํ•ดํ•˜๋ฉด z-index๋ฅผ ์ดํ•ดํ•˜๊ธฐ๊ฐ€ ์‰ฌ์›Œ์ง‘๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ์š”์†Œ(element)๋Š” stacking context๋ฅผ ํ˜•์„ฑํ•˜๊ฒŒ ๋˜๋Š”๋ฐ ์ž์‹ ์š”์†Œ๋“ค์ด stacking context ์—์„œ ํŠน์ • ๋ฒ”์œ„๋ฅผ ๋ฒ—์–ด๋‚˜์ง€ ๋ชปํ•˜๋„๋ก ํ•œ๊ณ„๋ฅผ ์ •ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ž์‹์š”์†Œ๋“ค์ด z-index๋ฅผ ์•„๋ฌด๋ฆฌ ๋งŽ์€ ์ˆซ์ž๋กœ ์ง€์ •ํ•˜๋”๋ผ๋„ ์ƒ์œ„ ์š”์†Œ๋ณด๋‹ค ๋” ์•ž์— ๋‚˜์˜ฌ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

์Šคํƒ ์ปจํ…์ŠคํŠธ๋Š” ๋ฌธ์„œ์˜ ์–ด๋Š ์œ„์น˜์—์„œ๋‚˜ ๋‹ค์Œ ์‹œ๋‚˜๋ฆฌ์˜ค์˜ ์š”์†Œ์— ์˜ํ•ด ํ˜•์„ฑ๋ฉ๋‹ˆ๋‹ค.

  • opacity ๊ฐ’์ด 1์ดํ•˜ ์ผ ๋•Œ,
  • mix-blend-mode ๊ฐ’์ด normal์ด ์•„๋‹Œ ๋‹ค๋ฅธ๊ฐ’ ์ผ ๋•Œ,
  • transform,filter, perspective, clip-path,mask / mask-image / mask-border ์˜ ๊ฐ’์ด non์ด ์•„๋‹Œ ๋‹ค๋ฅธ ๊ฐ’๋“ค์ผ ๋•Œ
  • isolation ์†์„ฑ์˜ ๊ฐ’์ด isolate ์ผ ๋•Œ
  • -webkit-overflow-scrolling์˜ ๊ฐ’์ด touch ์ผ ๋•Œ.
  • will-change ์†์„ฑ์˜ ๊ฐ’์ค‘ initial value๊ฐ€ ์•„๋‹Œ ๊ฐ’ ์ผ ๋•Œ.
  • contain ๊ฐ’์ด layout or paint ์ผ ๋•Œ. ๋˜๋Š” ๋‘˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ํฌํ•จํ•˜๋Š” ๋ณตํ•ฉ ๊ฐ’(์ฆ‰ contain: strict, contain: content)์ž…๋‹ˆ๋‹ค.

์ฐธ๊ณ ์ž๋ฃŒ MDN: Stacking context

๊ฒฐ๊ตญ Safari ์—”์ง„์˜ stacking context ์ฒ˜๋ฆฌ ๋ฌธ์ œ๋Š” z-index๋ฅผ ์œ ์ง€ํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์ด๊ณ  ์ƒˆ๋กœ์šด stacking context๋ฅผ overflow๊ฐ€ ์ ์šฉ๋œ ์š”์†Œ์— ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค.

5. ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

์œ„์—์„œ ์–ธ๊ธ‰ํ•œ stacking context๋ฅผ ํ˜•์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•๋“ค ์ค‘ ํ•œ๊ฐ€์ง€๋ฅผ ์ ์šฉํ•ด ๋ด…๋‹ˆ๋‹ค. z-index๋ฅผ ์ ์šฉํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

<GatsbyImage image={thumbnail} alt={post.imageAlt} css={css` border-radius: 12px; z-index:1 `} />

Screen Shot 2021-12-17 at 12 54 52 PM

๋‹ค๋ฅธ ์†์„ฑ์„ ์ถ”๊ฐ€ํ•ด๋„ ์ƒˆ๋กœ์šด stacking์ด ๋งŒ๋“ค์–ด์ง‘๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ๋ถ„๋“ค์€ ์–ด๋–จ์ง€ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ์ €์˜ ๊ฒฝ์šฐ๋Š” ์Šคํƒ ์ปจํ…์ŠคํŠธ๋ฅผ ์ ์šฉํ•จ์œผ๋กœ์จ ๋ ˆ์ด์–ด๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์œ„์˜ ๋ถ€๋ถ„์€ ๊ฐ ํฌ์ŠคํŒ… ๋งˆ๋‹ค ์ ์šฉ๋œ ์ด๋ฏธ์ง€๋กœ ํฌ์ŠคํŒ…์˜ ๊ฐœ์ˆ˜๋งŒํผ ํ•œ ํŽ˜์ด์ง€์˜ ํฌ์ŠคํŒ… ๊ฐœ์ˆ˜๋งŒํผ ์ถ”๊ฐ€ ๋œ ๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Screen Shot 2021-12-17 at 11 46 31 AM

Screen Shot 2021-12-17 at 1 10 51 PM

โ—๏ธ ์ฃผ์˜ํ• ์  ๋„ˆ๋ฌด ๋งŽ์€ ์š”์†Œ์— will-change๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ปดํ“จํ„ฐ์˜ ์ถ”๊ฐ€ ๋ฆฌ์†Œ์Šค ์†Œ๋น„๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ ํŽ˜์ด์ง€๋กœ๋“œ ์†๋„๊ฐ€ ๋Š๋ ค์ง‘๋‹ˆ๋‹ค.


์ฐธ๊ณ ์ž๋ฃŒ

Hi, I'm Hyunsu ๐Ÿ‘‹

Profile Image

์•ˆ๋…•ํ•˜์„ธ์š”. ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž ์ฃผํ˜„์ˆ˜์ž…๋‹ˆ๋‹ค.

๊ฐœ๋ฐœ์„ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ํ’๋ถ€ํ•˜๊ณ  ๊ฐ€์น˜ ์žˆ๋Š” ๊ฒฝํ—˜์„ ์ œ๊ณตํ•˜๋Š” ์ผ์— ๋ฟŒ๋“ฏํ•จ์„ ๋Š๋‚๋‹ˆ๋‹ค.

์˜ต์‹œ๋””์–ธ(Obsidian)์—์„œ ํ˜„์žฌ ๋ธ”๋กœ๊ทธ๋กœ ํ•˜๋‚˜์”ฉ ๊ธ€์„ ์˜ฎ๊ธฐ๋Š” ๊ณผ์ •์— ์žˆ์–ด์š”. โ˜•๏ธ ๐Ÿ‘ฉโ€๐Ÿ’ป โ›ท

Github on ViewReach Me Out