[CSS] Intrinsic Size vs Extrinsic Size

이슈에서 레이아웃이 깨진다는 요청이 들어왔다.

그리고 레이아웃이 깨진다면 안되니까 고쳐달라는…..

대충 이렇게 생긴 것이었는데… 이걸 보고 생각이 들었다. 음 나는,,,, ‘세트’ 라고 생긴 label과 ‘abs +1’ label은 자기 자신의 content만큼 무조건 width를 가지고 [혈액화학] 개 심장 바이오마커… 라고 적힌 애들이 overflow시 clip이 되면 되는…?

그렇게 하다보니 자연스럽게 min-width: min-content 를 하면 된다 생각했다.

‘이 녀석의 min-width는 content의 minimum width로 해줘! 그러면 주변의 여유 width가 없어도 줄어들지 않겠지.’

아니더라고…

min-width: max-content 를 하니 해결이 되었다.

근데 그래서 궁금해진것인데..도대체 intrinsic size란 무엇일까?

Intrinsic size has the same meaning for images as for text — the size at which the images are displayed if no CSS is applied to change the rendering. - Intrinsic Size

HTML Elements have a natural size, set before they are affected by any CSS. A straightforward example is an image. An image file contains sizing information, described as its intrinsic size. This size is determined by the image itself, not by any formatting we happen to apply. - Sizing items in CSS

그러니까… HTML Element들은 CSS가 적용되기전 본래의 사이즈를 가지고 있다. 가장 쉬운게 이미지. 이미지에 아무런 사이즈 요소들을 주지 않으면, 그 이미지는 이미지 파일 내에 있는 사이즈 정보를 가지고 화면에 나타날 것이다. 텍스트도 똑같다. 텍스트가 있으면… 그 텍스트에 어떠한 css가 가해지지 않았을 때 가지고 있는 사이즈가 intrinsic size임.

그렇다면 Extrinsic size란?

We can, of course, give elements in our design a specific size. When a size is given to an element (the content of which then needs to fit into that size) we refer to it as an extrinsic size. Take our <div> from the example above — we can give it specific width and height values, and it will now have that size no matter what content is placed into it. - Sizing items in CSS

div를 예시로 들어보면.. 빈 div를 생성해주면 height: 0, width: 0 도 0 일것이다. 왜냐하면 intrinsic size 자체가 없으니까. 그런데 이 div에다가 width, height를 주면 거기에 알맞게 div가 변할것이다. 그래서 외부적으로 사이즈가 정해진 것을 extrinsic size라고 한다.

그러면 여기서… 나는 어떻게 아래의 조건을 만족시켰을까?

‘세트’ 라고 생긴 label과 ‘abs +1’ label은 자기 자신의 content만큼 무조건 width를 가지고 [혈액화학] 개 심장 바이오마커… 라고 적힌 애들이 overflow시 clip

min-width: max-content 를 통해서이다. 무슨 뜻이냐면, content의 maximum intrinsic size를 의미하는데 텍스트에서 의미하는 것은 overflow를 일으키더라도 이 text는 절대 soft-wrapping을 하지 않는 것이다. min-content 는 soft-wrapping 기회가 있으면 무조건 한다. 그래서… overflow를 일으키지 않지.

그런데 약간 이상하기는 하단 말이야. ‘세트’ 라는 단어에는 soft-wrapping을 할 기회가 없거든… 빈 칸이 있는 것도 아니고…

참조