2026. 4. 11. 21:45ใTrouble Shooting & Issues/Linkiving

flex-shrink์ ๋์ ์์ ์ดํดํ๊ธฐ
๋ชฉ์ฐจ
1. ๋ฌธ์ ์ํฉ: div ๋ด์์ hover ์ ๋ณด์ด๋ ์ปดํฌ๋ํธ๊ฐ ์ฐ๊ทธ๋ฌ์ง
2. ํด๊ฒฐ1: ๊ณ ์ ๋๋น๋ฅผ ์ง์ฐ๊ณ IconButton์ shrink-0 ์ฃผ๊ธฐ
3. ํด๊ฒฐ2: IconButton์ block ๋์ ์ flex ์ฃผ๊ธฐ
1. ๋ฌธ์ ์ํฉ: div๋ด์์ hover ์ ๋ณด์ด๋ ์ปดํฌ๋ํธ๊ฐ ์ฐ๊ทธ๋ฌ์ง
์ธ๋ค์ผ์์๋ ์๋ณด์ด๋ผ๊ณ IconButton์ ์ผ๋ถ๋ฌ ๊ฒ์ ์์ผ๋ก ๋๋๋ฐ, ์ค์ ๋์์ธ์ ์ผ์ชฝ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด ๋ฐฐ๊ฒฝ๊ณผ ๋น์ทํ ํ๋์์ด๋ค.
ํฐ๊ฐ ์ ์๋๋ค๊ณ ์๊ฐํด์ ์ฐ๊ทธ๋ฌ์ง ์ํ๋ก ๋๊ณ ์ผ๋จ ๋ค๋ฅธ ๋ ๊ธํ ์์ ๋ค์ ์งํํ๋ค๊ฐ
ํผ๋๋ฐฑ ๋ฐฉ์๋ ์ฌ๋ผ์ค๊ณ , ๋ ์ค์ํ ๊ธฐ๋ฅ๋ค์ด ์ข ์์ฑ์ด ๋ผ์ ๋๋์ด ๊ณ ์น๊ธฐ ์์..
๊ฐ๋จํ ๋ถ๋ถ์ด์ง๋ง ์๊ทผ ํค๋ฉจ์์ด์ ๋ธ๋ก๊ทธ๋ฅผ ์์ฑํด๋ณธ๋ค.


ํด๋น ๋ถ๋ถ์ ์๋์ ๊ฐ์ ํํ๋ก ๊ตฌํ๋์ด ์์๋ค.
return (
<>
<div
className="group bg-btn-tertiary-subtle-onpanel flex h-9 w-48.5 cursor-pointer items-center justify-between rounded-full pr-3 pl-3 transition-colors hover:pr-1"
...
>
<span className="font-label-md text-gray500 group-hover:text-gray700 truncate group-hover:w-46">
{label}
</span>
<Popover>
<PopoverTrigger popoverKey="chat_more">
<IconButton
...
className="hidden pl-1 group-hover:block"
/>
</PopoverTrigger>
<PopoverContent popoverKey="chat_more">
...
</PopoverContent>
</Popover>
</div>
</>
);
<div> ํ๊ทธ ์์ Label, IconButton์ด ๋ค์ด๊ฐ ์๋ ํํ์ด๋ค.
์ฒ์์ ์ ๋ ๊ฒ ๋ง ๋ฃ์๋๋ IconButton์ด ์ฐ๊ทธ๋ฌ์ง + ์คํฌ๋กค์ ์์ดํ ์ด ์๋ฆผ์ผ๋ก ์ธํด w-48.5, w-46, pl-1 ์ด๋ฐ ๊ฒ๋ค์ด ๋ค์ด๊ฐ์๋ค.
flex ๋ ์ด์์์์ ๊ณต๊ฐ์ด ๋ถ์กฑํ ๋ flex-shrink๊ฐ ๋์ํ๋ฉฐ IconButton์ด ์์ถ๋ ๋ฌธ์ ์๋ค.
IconButton์ ์๋์ ๊ฐ์ ์คํ์ผ๋ง์ด ์ ์ฉ๋์ด ์๋ค.
className="hidden group-hover:block"
์ด๋ ํ๋ฉด์ ์กด์ฌํ์ง ์๋ IconButton์ด hover๋ก ์๋ก ๋ ์ด์์์ ์ฐธ์ฌํ๋ฉฐ ๊ณต๊ฐ ์ฌ๋ถ๋ฐฐ๊ฐ ๋ฐ์ํ๋ค.
์ด ์๋ก ์ถ๊ฐ๋๋ IconButton์ ์ํด์ ์ ์ฒด div์๋ hover:pr-1์ด ์ ์ฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์ธ pr-3์ IconButton์ด ๋ค์ด์์ ๋ ๋๋ฌด ๋์ด๋ณด์ด๊ธฐ ๋๋ฌธ์ด๋ค.
label์๋ hover:w-46, div๋ w-48.5๋ก ๊ณ ์ ๋ ๋๋น๋ฅผ ๊ฐ์ ธ์ ํจ๋ฉ๊ฐ์ผ๋ก width๋ฅผ ์ฐจ์งํ๋ IconButton์ด ์ฐ๊ทธ๋ฌ์ง ๊ฒ์ด๋ค.
2. ํด๊ฒฐ1: ๊ณ ์ ๋๋น๋ฅผ ์ง์ฐ๊ณ IconButton์ shrink-0 ์ฃผ๊ธฐ
์ฐ์ ๊ณ ์ ๋๋น๊ฐ ์๋ ๋ชจ์์ด ์ด์ํด์ ๊ณ ์ ๋๋น๋ฅผ ์ง์๋ดค๋๋ฐ ์คํฌ๋กค๋ฐ์ ์ํด ์๋ฆฌ๊ฑฐ๋ ํ์ง ์์๋ค.
๊ณผ๊ฑฐ์ ๋ด๊ฐ ์ ๊ทธ๋ ๊ฒ ํ๋์ง ๋ชจ๋ฅด๊ฒ ๋..
ํ์ง๋ง IconButton์ ์ฌ์ ํ ์ฐ๊ทธ๋ฌ์ ธ์์๋ค. ์์ผ๊น?
flex item์ ์๋์ ๊ฐ์ ๊ธฐ๋ณธ๊ฐ์ ๊ฐ์ง๋ค.
min-width: auto; /* min-content size๋ฅผ ๋ฐ๋ฆ */
flex-shrink: 1; /* ๊ณต๊ฐ์ด ๋ถ์กฑํ๋ฉด ํด๋น ์์๋ฅผ ์ค์ด๊ฒ ๋ค */
flex item์ ๊ธฐ๋ณธ๊ฐ์ธ min-width: auto๋ <span>์ ๋ค์ด๊ฐ๋ ๊ธ์ ์๋งํผ ์ต์ ๋๋น๋ฅผ ํ๋ณดํ๋ ค๊ณ ํ๋ค.
IconButton์ด ๊ฐ์ง px๋ ์ ๋ฐ ์ต์ ๋๋น ๊ณ์ฐ์ ๋ค์ด๊ฐ์ง ์๊ธฐ ๋๋ฌธ์ IconButton์ด ์ฐ๊ทธ๋ฌ์ง๋ ๊ฒ์ด๋ค.
๊ทธ๋ ๋ค๋ฉด span์ min-w-0์ ์ฃผ๋ฉด ์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ์ด ๋ ๊น? ๊ทธ๊ฒ๋ ์๋๋ค.
ํ์ฌ span, IconButton์ ๋๋ค ๊ธฐ๋ณธ๊ฐ์ผ๋ก flex-shrink: 1์ ๊ฐ์ง๋ค.
flex-shrink์ ๋ฐฐ๋ถ ๋ฐฉ์์ ๋ํด ์์๋ณด์.

์์ปจ๋, flex-shrink๊ฐ 0์ด๋ฉด ์๊ณ ๋ฆฌ์ฆ์ a๋จ๊ณ์์ ๊ณต๊ฐ ๋ฐฐ๋ถ ๊ณ์ฐ ์์ฒด์์ ์ ์ธ๋ ์ฑ ๊ณต๊ฐ์ ์ ์งํ์ง๋ง,
๊ธฐ๋ณธ๊ฐ์ธ 1์ ๊ฐ์ง๋ฉด ๋น์จ์ ๋ฐ๋ผ์ ์ค์ด๋ค ๋ชซ์ ๋๋ ๋ฐ๊ณ ์ค์ด๋ค๊ฒ ๋๋ ๊ฒ์ด๋ค.
min-w-0์ ์ฃผ๋ฉด '0๊น์ง ์ค์ด๋ค ์ ์๋ค'๋ฅผ ๋ํ๋ด๋ ๊ฒ์ด์ง, ์์ค์ด๋ค๊ฒ ๋ค๋ ๊ฒ ์๋๋ผ๋ ๊ฒ.
๋ฐ๋ผ์ IconButton์ด ์์ ์ค์ด๋ค์ง ์๋๋ก ํ๋ ค๋ฉด shrink-0์ ์ฃผ์ด์ผ ํ๋ ๊ฒ์ด๋ค.
๊ทธ๋ผ IconButton์ shrink-0๋ง ์ฃผ๋ฉด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋ ๊ฑธ๊น?

์ํ๊น์ง๋ง ์๋๋ค!
IconButton ์์ฒด๊ฐ ์ฐ๊ทธ๋ฌ์ง์ง๋ ์์๋๋ฐ, ์ ์ค์์ ์์ด์ผํ ์์ด์ฝ์ ์์น๊ฐ ์ด์ํด์ก๋ค.
3. ํด๊ฒฐ2: IconButton์ block ๋์ flex ์ฃผ๊ธฐ
์ฌ์ค IconButton ๋ด๋ถ์์ Icon์ ์์น๊ฐ ์ด์ํด์ง๋ ์ด์ ๋ ๋ช ํํ๋ค.
<IconButton
contextStyle="onPanel"
size="sm"
icon="IC_MoreVert"
ariaLabel="์ฑํ
๋ฐฉ ๋ฉ๋ด ๋๋ณด๊ธฐ ๋ฒํผ"
className="hidden shrink-0 group-hover:block"
onClick={handleButtonClick}
/>
flex์ ์์ฑ์ ๋ฏธ์ฒ ์๊ฐํ์ง ๋ชปํ๊ณ '์๋ณด์ด๋ค๊ฐ hoverํ๋ฉด ๋ณด์ด๋๋กํ ๋ ๋ณดํต hidden, block์ ์ฌ์ฉํ์ง!' ์ด ๊ฒฝํ/์๊ฐ์ ๊ฝํ์
IconButton์ className์ผ๋ก block์ ๋ฎ์ด์จ๋ฒ๋ ธ๊ธฐ ๋๋ฌธ์ด๋ค.
Icon์ด ์ ์ค์์ ์์ ์ ์๋ ์ด์ ๋ flex์ ํจ๊ป ์ฌ์ฉํ๋ items-center, justify-center ๋๋ถ์ด๋ค.
๋ฐ๋ผ์ ์์์ block ๋์ flex๋ฅผ ์ฃผ๋ฉด ์ฐ๊ทธ๋ฌ์ง๋ ๋ฌธ์ ๊ฐ ์์ ํ ํด๊ฒฐ๋๋ค.
ํฌ๊ฒ ๋ณ ๊ฒ ์์๋ ๊ฑด ์๋์ง๋ง flex-shrink๊ฐ ๋์ํ๋ ๊ณผ์ ์ ๋ํด ์ข ๋ ์์ธํ ์๊ฒ๋ ๊ฒ ๊ฐ์์ ์ ๋ฆฌํด๋ดค๋ค.
w3.org๋ฅผ ํ์์ ์ ๋ ํ๋ฉด์ ๊ณต๋ถํ ์๋ ์๊ฒ ์ง๋ง ์ด๋ฐ ์์ผ๋ก ๋ฌธ์ ์๊ฒผ์ ๋ ํ๋ฒ์ฉ ์ฝ์ด๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค.
ํนํ flex์ ๋ํด์๋ ์ฌ์ค ํฌ์ง์ ๋ ํค์๋์ ๋์ ์์ฒด๋ง ์๊ณ ์์ผ๋ฉด ์ถฉ๋ถํ๋ค ์๊ฐํ์๋๋ฐ
๋ฌธ์ ๋ ๊ทธ ๋์์ด ์ด๋ป๊ฒ ์งํ๋๋์ง ๋ชจ๋ฅด๋ ๋ฐ์์๋ ๋ฐ์ํ ์ ์๋ค๋ ๊ฒ์ ์์๋ค.
๋จ์ .. ๊ฐ๋ ์ฑ ๊ฝค ๋จ์ด์ง๊ณ ํ๊ตญ์ด๊ฐ ๋ง์ด ๋ถ์คํด์ ์์ด๋ก ์ฝ์ด์ผํจ
์ฐธ๊ณ
https://www.w3.org/TR/css-flexbox-1/#resolve-flexible-lengths
CSS Flexible Box Layout Module Level 1
This section is not normative. CSS 2.1 defined four layout modes — algorithms which determine the size and position of boxes based on their relationships with their sibling and ancestor boxes: This module introduces a new layout mode, flex layout, which
www.w3.org
'Trouble Shooting & Issues > Linkiving' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| ๋ฌดํ์คํฌ๋กค ์ฑ๋ฅ ์ธก์ /๊ฐ์ ํ๊ธฐ(2) (0) | 2026.04.04 |
|---|---|
| ๋ฌดํ์คํฌ๋กค ์ฑ๋ฅ ์ธก์ /๊ฐ์ ํ๊ธฐ(1) (0) | 2026.04.03 |
| 401 Unauthorization ์๋ฌ์ ์์ธ ์ฐพ๊ธฐ (1) | 2026.03.12 |
| Docker ์ค์นํด์ ๋ฐฑ์๋ ๋ก์ปฌ๋ก ๋ก๊ทธ์ธ ํ ์คํธํ๊ธฐ [Linkiving] (0) | 2026.02.27 |
| safeFetch ์ ํธํจ์ ๋ง๋ค๊ธฐ(2): safeFetch ํจ์ ์์ฑ (0) | 2025.12.12 |
GitHub