๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ปSTUDY/CSS

[CSS] height: 100% VS height: auto

๋ฐ˜์‘ํ˜•

[CSS] height: 100% / height: auto;

  • height: 100%;

    • ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ์˜ ๋†’์ด๋ฅผ 100% ๋กœ ์„ค์ •ํ•œ๋‹ค. (๋ถ€๋ชจ๋†’์ด ์˜ํ–ฅ)
<div style="height: 50px">
  <div id="innerDiv" style="height: 100%"></div>
</div>

#innerDiv ๋Š” height: 50px

 

  • height: auto;

    • ๋†’์ด๋Š” ์ž์‹์˜ ๋†’์ด์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง„๋‹ค. (์ž์‹๋†’์ด ์˜ํ–ฅ)
<div style="height: 50px">
  <div id="innerDiv" style="height: auto">
    <div id="evenInner" style="height: 10px"></div>
  </div>
</div>

#innerDiv๋Š” height: 10px

 

 

Reference

https://stackoverflow.com/questions/15943009/difference-between-css-height-100-vs-height-auto

๋ฐ˜์‘ํ˜•