TD and box sizing
TD defaults to box-sizing: content-box. How does box-sizing affect final TD size?
- Auto table layout
- Percent cells ignore box-sizing, it is always border-box.
- Fixed cells respect box-sizing.
- Fixed table layout
- Percent cells respect box sizing when computing cell width from assignable width.
- Percent cells ignore box sizing when computing grid max from cell width.
Table-layout: auto
TD width:%
content-box, C0:50%/100 C1:Auto
Percent gets resolved to compute grid max size.
C0 max_width is max_width + 2 padding = 100 + 2*20 = 140
Table width is 1/50%*140 + 3*padding = 280+30 = 310
border-box, C0:50%/100 C1:Auto
Same test as above, but box-sizing is border-box.
content-box, C0:80%/100 C1:Auto
Percent gets resolved to compute final cell size from assignable width.
C0 border box width is 500 * 80%
border-box, C0:80%/100 C1:Auto
Same as above, but border-box
TD width:fixed
content-box, C0:100/Auto C1:100/Auto
Tests whether box-sizing affects how percentages are computed.
C0 max_width is max_width + 2 padding = 100 + 2*20 = 140
Table width is 1/50%*140 + 3*padding = 280+30 = 310
border-box, C0:100/Auto C1:100/Auto
Same test as above, but box-sizing is border-box.
TD height: fixed
content-box, C0 height:100px
border-box, C0 height:100px
Table-layout: fixed
TD width:%
content-box, C0:50%/100 C1:Auto
Percent gets resolved to compute grid max size.
C0 max_width is max_width + 2 padding = 100 + 2*20 = 140
Table width is 1/50%*140 + 3*padding = 280+30 = 310
border-box, C0:50%/100 C1:Auto
Same test as above, but box-sizing is border-box.
content-box, C0:60%/100 C1:Auto
Percent gets resolved to compute final cell size from assignable width.
Assignable width is 530 - 3*10 = 500
C0 content box width is 500 * 60% + 40px padding = 340
C1 is 500 - 340 = 160
Legacy/Edge treat %ge TD as border box, and end up with 300px
border-box, C0:60%/100 C1:Auto
Same as above, but border-box
TD width:fixed
content-box, C0:100/Auto C1:100/Auto
Tests whether box-sizing affects how percentages are computed.
C0 max_width is max_width + 2 padding = 100 + 2*20 = 140
Table width is 1/50%*140 + 3*padding = 280+30 = 310
border-box, C0:100/Auto C1:100/Auto
Same test as above, but box-sizing is border-box.