我希望使它成为 11 个 html div 的纯响应式 css 网格。
<div class="dashboard page-container">w100%, h100%
<div class="box1">w20%, h25%</div>
<div class="box2">w20%, h25%</div>
<div class="box3">w20%, h25%</div>
<div class="box4">w20%, h25%</div>
<div class="box5">w35%, h30%</div>
<div class="box6">w30%, h65%</div>
<div class="box7">w15%, h90%</div>
<div class="box8">w35%, h35%</div>
<div class="box9">w65%, h15%</div>
<div class="box10">w65%, h20%</div>
<div class="box11">w15%, h10%</div>
</div><!--/dashboard-->
在容器宽度为 100% 和高度为 100% 的意义上响应,
..每个框占页面容器的百分比。
一直在努力,但还没有让花车正常工作。感谢对此的任何帮助
最佳答案
此解决方案使用 float 。
我不得不调换框的顺序并向您的原始 HTML 标记添加 2 个容器。
HTML:
<div class="dashboard page-container">
<div class="col1">
<div class="box1">w20%, h25%</div>
<div class="box2">w20%, h25%</div>
<div class="box3">w20%, h25%</div>
<div class="box4">w20%, h25%</div>
</div>
<div class="col2">
<div class="box6">w30%, h65%</div>
<div class="box5">w35%, h30%</div>
<div class="box8">w35%, h35%</div>
<div class="box9">w65%, h15%</div>
<div class="box10">w65%, h20%</div>
</div>
<div class="box7">w15%, h90%</div>
<div class="box11">w15%, h10%</div>
</div><!--/dashboard-->
CSS:
html, body, .dashboard {
width:100%;
height:100%;
margin:0;
}
.col1, .col2, .box7, .box11 {
float:left;
}
.col1 {
width:20%;
height:100%;
}
.col1 > div {
width:100%;
height:25%;
}
.col2 {
width: 65%;
height:100%;
}
.box6 {
float:right;
width: 47.5%;
height:65%;
}
.box5, .box8 {
width:52.5%;
}
.box5 {
height:30%;
}
.box8 {
height:35%;
}
.box9 {
height:15%;
}
.box10 {
height:20%;
}
.box7, .box11 {
width:15%;
}
.box7 {
height:90%;
}
.box11 {
height:10%;
}
/* following just to see what we are doing :) */
div {
border:2px solid red;
box-sizing:border-box;
}
关于html - 响应式网格布局 - 仪表板样式 - 100% 高度和宽度的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22930107/