Several ways to change the number of box columns as the browser width changes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.