It can be compatible with all browsers, but some hacks need to be used to solve the problem of float positioning, and clearing of floats needs to be considered.
In the case where many proportions (1/3, 2/3 are the most common cases) are not divisible, an error of 1px occurs in some cases.
Horizontal split plan B: percentage width inline-box without gap
The disadvantages are the same as above. The amount of hacks is about the same as Plan A.
The additional benefit is that there are many vertical-align methods that can be specified. The additional disadvantage is that many vertical-align attribute values are different for each browser. The most common vertical-align is still middle and baseline, with top and bottom added at most.
Horizontal split plan C: Table
Using tables is of course an option supported by all browsers.
Horizontal split plan D: display attribute instead of table
Replace tables with attributes such as display:table and display:table-cell to take into account semantics. IE8 and modern browser support.
More forward-looking attributes...
Use css3’s new feature calc to calculate values float/inline-box
Use flexbox
The following introduces a set of reusable solutions for bootstrap. This set of solutions is developed from solution A. The main idea is to extract reusable classes in the layout.
The core of bootstrap's grid system is to use such a three-layer structure, and the innermost layer uses width to allocate 100% of the parent width.
The class name rule for a single column is: col-[lg/md/sm/xs]-[1~12]. See bootstrap grid options for details.
The middle variable is related to responsive media query and will not be explained in detail here. The last value x is equal to 1/12 of the parent container multiplied by x. As follows:
bootstrap uses * to select all elements (this is the reason why I am tired of bootstrap, sacrificing selector efficiency for development efficiency), and forces the use of border-box to calculate the width, thus achieving a large layout Harmony has this calculation formula:
(The above uses jade’s syntax to display the hierarchy, and bootstrap’s holder.js to supplement an img element to display the effect). The effect is as follows:
The bootstrap solution is applicable to IE8 and other modern browsers. In this solution, the main problem lies in the compatibility of the box-sizing attribute. The minor flaw is the ±1px error caused by the percentage width.
Horizontal split plan A: percentage width float
It can be compatible with all browsers, but some hacks need to be used to solve the problem of float positioning, and clearing of floats needs to be considered.
In the case where many proportions (1/3, 2/3 are the most common cases) are not divisible, an error of 1px occurs in some cases.
Horizontal split plan B: percentage width inline-box without gap
The disadvantages are the same as above. The amount of hacks is about the same as Plan A.
The additional benefit is that there are many vertical-align methods that can be specified. The additional disadvantage is that many vertical-align attribute values are different for each browser. The most common vertical-align is still middle and baseline, with top and bottom added at most.
Horizontal split plan C: Table
Using tables is of course an option supported by all browsers.
Horizontal split plan D: display attribute instead of table
Replace tables with attributes such as display:table and display:table-cell to take into account semantics. IE8 and modern browser support.
More forward-looking attributes...
The following introduces a set of reusable solutions for bootstrap. This set of solutions is developed from solution A. The main idea is to extract reusable classes in the layout.
A common column split is as follows:
The core of bootstrap's grid system is to use such a three-layer structure, and the innermost layer uses width to allocate 100% of the parent width.
The class name rule for a single column is: col-[lg/md/sm/xs]-[1~12]. See bootstrap grid options for details.
The middle variable is related to responsive media query and will not be explained in detail here. The last value x is equal to 1/12 of the parent container multiplied by x. As follows:
In the bootstrap grid system, there is a 30px gap between each col. How to divide the gap equally? See the following CSS properties:
Wait, is there something wrong? Calculate the width:
How come each one is divided equally into 1/4 of the parent container?
There is also this attribute in action:
bootstrap uses * to select all elements (this is the reason why I am tired of bootstrap, sacrificing selector efficiency for development efficiency), and forces the use of border-box to calculate the width, thus achieving a
large layout Harmonyhas this calculation formula:After doing this, you can easily use the corresponding class, or you can cascade it, similar to row-col-row-col-row-col...
(The above uses jade’s syntax to display the hierarchy, and bootstrap’s holder.js to supplement an img element to display the effect). The effect is as follows:
The bootstrap solution is applicable to IE8 and other modern browsers. In this solution, the main problem lies in the compatibility of the box-sizing attribute. The minor flaw is the ±1px error caused by the percentage width.
I think it can be similar to the navigation bar
http://thjiang.sinaapp.com/59
width is the same, float:left