1, equal-ratio scaling layout
Creating a scaling layout is a way to divide a page into columns and then set their widths in proportions rather than pixels. Take the following two column layouts for example:
<!doctype html>
<meta charset= "UTF-8" >
<title>111cn.net</title>
<style>
* {
margin:0px;
padding:0px;
}
. leftcolumn {
width:33.3%;
Float:left;
Background-color:yellow;
height:300px;
}
. rightcolumn {
width:66.7%;
Float:left;
Background-color: #7FFF9B;
height:300px;
}
</style>
<body>
<div class= "Leftcolumn" >
Left
</div>
<div class= "Rightcolumn" >
Right
</div>
</body>
2, the width of the outer margin set
When using a streaming layout, in addition to the column width to use the percentage setting, the outer margin must also use a percentage (cannot use fixed pixel values) to ensure the column width + margin =100%.
The following is a 2% margin added to the left, right, and between columns:
. leftcolumn {
width:31.3%;
margin-left:2%;
margin-right:2%;
Float:left;
Background-color:yellow;
height:300px;
}
. rightcolumn {
width:62.7%;
margin-right:2%;
Float:left;
Background-color: #7FFF9B;
height:300px;
}
3, the setting of the border
Because the border is added to the perimeter of the element, and the border width does not accept a percentage value, setting a fixed-width border directly on the bar destroys the flow layout.
The solution is to add an additional <div> element to the zoom bar, and set the border to the <div> element.
<!doctype html>
<meta charset= "UTF-8" >
<title>111cn.net</title>
<style>
* {
margin:0px;
padding:0px;
}
body{
Background-color: #EFEFEF;
}
. leftcolumn {
width:31.3%;
margin-left:2%;
margin-right:2%;
Float:left;
Background-color:yellow;
}
. rightcolumn {
width:62.7%;
margin-right:2%;
Float:left;
Background-color: #7FFF9B;
}
. colomncontent {
border:1px solid Gray;
height:130px;
}
</style>
<body>
<div class= "Leftcolumn" >
<div class= "Colomncontent" >
Left
</div>
</div>
<div class= "Rightcolumn" >
<div class= "Colomncontent" >
Right
</div>
</div>
</body>