Several ways to change the number of box columns as the browser width changes
One, use float float
<!DOCTYPE HTML><HTML><HeadLang= "en"><MetaCharSet= "UTF-8"><title>Investigate floating</title><styletype= "Text/css">#content{Background-color:Red;position:relative;padding:12px;/*The margin of Red's Padding+blue = width of the measurement*/Overflow:Hidden;/*parent Element Overflow:hidden can be closed floating*/ }. Div-in{width:107px;Height:54px;Background-color:Blue;margin:6px;/*the distance between the measurements is 121 and a half is 6.*//*margin does not merge because float, normal position is merged*/Border:Solid 1px #000000;float: Left;}</style></Head><Body><DivID= "Content"><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div><Divclass= "Div-in">111</Div></Div></Body></HTML>
Under normal circumstances, the div and Div measured between 12 is set 12 is good, but this is floating, floating margin does not merge, will be superimposed, so the overlay is 12px, then each blue div margin is set to 6px;
Also measures the red background border according to the nearest blue div distance is 18px =6+12;
So set the outer div padding:12px
Closed float I set the overflow:hidden here with the parent element.
For reference: Those years we cleaned up the float
II to be continued:
Several ways to change the number of box columns as the browser width changes