๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ป DEV/Tailwind CSS

[Tailwind CSS] 17. sticky top-0 & backdrop-blur

by Rising Oneโ˜… 2025. 6. 19.
728x90
๋ฐ˜์‘ํ˜•
SMALL

 

tailwind CSS ๋กœ๊ณ 

 

 

์š”์•ฝ  

  1. ํ•™์Šต๋‚ด์šฉ : sticky top-0

 

  2. ํ•™์Šต๋‚ด์šฉ : backdrop-blur



์ƒ์„ธ
  1. ํ•™์Šต๋‚ด์šฉ : sticky top-0

 

โ—ผ๏ธŽ sticky top-0 ์ •์˜

- position: sticky : ์Šคํฌ๋กค ์œ„์น˜์— ๋”ฐ๋ผ ์š”์†Œ๊ฐ€ ํ˜๋Ÿฌ๊ฐ€๋‹ค๊ฐ€ ํŠน์ • ์ž„๊ณ„์ ์— ๋„๋‹ฌํ•˜๋ฉด ๊ณ ์ •(sticky)๋˜๋Š” css

- relative์™€ fixed ์‚ฌ์ด์˜ ์„ฑ๊ฒฉ : ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ ์˜์—ญ ๋‚ด์—์„œ๋งŒ ๊ณ ์ •

sticky top-n : top-0 / top-4 / top-1/2 ๋“ฑ

 


โ—ผ๏ธŽ sticky top-0 ์šฉ๋ฒ•

return (
    <>
      <header className='sticky top-0'>
        <nav className='flex container max-w-4xl mx-auto px-6 py-3 justify-between items-center'>
          <div className='flex items-center space-x-4'>
            <p className='text-sm text-gray-500'>ใ„ฑใ„ดใ„ทใ„นใ…</p>
          </div>
          <div className='flex items-center gap-x-6'>
            <a href="#home" className='hover:text-blue-500 transition-colors'>ํ™ˆ</a>
          </div>
        </nav>
      </header>
    </>
  );

 

- header ํƒœ๊ทธ์— sticky top-0๋ฅผ ๋„ฃ์—ˆ๋‹ค.

 

๊ฒฐ๊ณผ๋ฌผ

 

- header ํƒœ๊ทธ๊ฐ€ ์ƒ๋‹จ top-0์— ๊ณ ์ •์ด ๋˜์–ด ์Šคํฌ๋กค์— ๋”ฐ๋ผ ์˜ฌ๋ผ์˜จ ์š”์†Œ๋“ค์ด ๊ฒน์ณ์ง„๋‹ค.

=> ๋ฐฐ๊ฒฝ์ƒ‰์— ๋Œ€ํ•œ ์ •์˜ ํ•„์š” 


  2. ํ•™์Šต๋‚ด์šฉ : backdrop-blur

 

โ—ผ๏ธŽ backdrop-blur-size ์ •์˜

- backdrop-filter : ์š”์†Œ ๋’ค(๋ฐฐ๊ฒฝ)์— CSS ํ•„ํ„ฐ(blur, brightness ๋“ฑ)๋ฅผ ์ ์šฉํ•˜๋Š” ์†์„ฑใ…‡

- relative์™€ fixed ์‚ฌ์ด์˜ ์„ฑ๊ฒฉ : ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ ์˜์—ญ ๋‚ด์—์„œ๋งŒ ๊ณ ์ •

backdrop-blur : backdrop-blur-lg / backdrop-blur-xl / backdrop-blur-none 

 


โ—ผ๏ธŽ backdrop-blur ์šฉ๋ฒ•

return (
    <>
      <header className='sticky top-0 bg-opacity-90 backdrop-blur-xl'>
        <nav className='flex container max-w-4xl mx-auto px-6 py-3 justify-between items-center'>
          <div className='flex items-center space-x-4'>
            <p className='text-sm text-gray-500'>ใ„ฑใ„ดใ„ทใ„นใ…</p>
          </div>
          <div className='flex items-center gap-x-6'>
            <a href="#home" className='hover:text-blue-500 transition-colors'>ํ™ˆ</a>
          </div>
        </nav>
      </header>
    </>
  );

- header ํƒœ๊ทธ์— backdrop-blur-xl ๋ฅผ ๋„ฃ์—ˆ๋‹ค

๊ฒฐ๊ณผ๋ฌผ

 

728x90
๋ฐ˜์‘ํ˜•
LIST

๋Œ“๊ธ€