I do not get the value auto. If applied to height, it will occupy the height of the child, but if applied to width, it will have the width of the parent.
There are no MDN values ββin the value itself auto, and Google gives "100% VS auto" and not "width: auto VS height: auto".
For my current needs, I would like the element to expand to its child's width, but overall I want to know what the deal is with auto.
.divXS {
width: 100px;
height: 100px;
background: green;
}
.divXXS {
width: 50px;
height: 50px;
background: yellow;
}
.divSM {
width: 200px;
height: 200px;
}
#Father {
background: blue;
border: 3px solid #20295E;
}
#Mother {
background: pink;
border: 3px solid #DB6DBE;
}
#Daughter {
width: 100%;
height: 100%;
}
#Son {
width: auto;
height: auto;
}
<div class="divSM" id="Mother">
<div class="divXS" id="Daughter">
<div class="divXXS" id="grandDaughter"></div>
</div>
</div>
<div class="divSM" id="Father">
<div class="divXS" id="Son">
<div class="divXXS" id="grandSon"></div>
</div>
</div>
Run codeHide resultjsFiddle / jsBin
source
share