code

div를 콘텐츠에 맞는 크기로 만드는 것이 정말 불가능합니까?

codestyles 2020. 10. 21. 08:07
반응형

div를 콘텐츠에 맞는 크기로 만드는 것이 정말 불가능합니까?


요소를 부동으로 만들거나 절대 위치를 만들 필요없이 콘텐츠 크기에 따라 div를 크기에 맞출 수 있는지 여부를 명확히하고 싶습니다. 가능합니까?


CSS display설정

물론 가능합니다-JSFiddle 개념 증명에서 세 가지 가능한 솔루션을 모두 볼 수 있습니다.

  • display: inline-block- 이것은 당신이 알지 못하는 것입니다

  • position: absolute

  • float: left/right


사용할 수 있습니다 display: inline-block.


당신이 사용할 수있는:

width: -webkit-fit-content;
height: -webkit-fit-content;
width: -moz-fit-content;
height: -moz-fit-content;

편집 : 아니요. http://red-team-design.com/horizontal-centering-using-css-fit-content-value/ 참조

또한 : http://dev.w3.org/csswg/css-box-3/


당신은 또한 사용할 수 있습니다

단어 분리 : break-all;

아무것도 작동하지 않을 때 항상 작동합니다.)

참고 URL : https://stackoverflow.com/questions/5903112/is-it-really-impossible-to-make-a-div-fit-its-size-to-its-content

반응형