์์ฝ
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 ๋ฅผ ๋ฃ์๋ค
'๐ป DEV > Tailwind CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Tailwind CSS] 16. clsx ์ฌ์ฉํ๊ธฐ (0) | 2025.06.19 |
---|---|
[Tailwind CSS] 15. flex flex-col items-center (0) | 2025.06.18 |
[Tailwind CSS] 14. DarkMode (๋คํฌ๋ชจ๋) (1) | 2025.06.13 |
[Tailwind CSS] 13. Animation (์ ๋๋ฉ์ด์ ) (0) | 2025.06.13 |
[Tailwind CSS] 12. Transition (ํธ๋์ง์ ) (0) | 2025.06.13 |
๋๊ธ