box size collapsing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

box size collapsing

why in this code, the box's size suddenly collapse and shrink from top and bottom when the top and bottom paddings are set to zero? it doesn't collapse even when it is 1px. but it nevertheless collapses when it is set to zero! I couldn't figure out what the problem exactly is https://code.sololearn.com/W0A1817a20A1

11th Mar 2021, 1:25 PM
salar vahidi
salar vahidi - avatar
1 Answer
+ 4
By default, the width and height of an element is calculated like this: width + padding + border = actual width of an element height + padding + border = actual height of an element So, when you set top and bottom paddings to zero.. that time your actual height is .... border + height + zero = actual height && Your header collapse.
16th Mar 2021, 3:56 AM
axita
axita - avatar