html - 响应式网格布局 - 仪表板样式 - 100% 高度和宽度的容器

标签 html css responsive-design grid-layout

我希望使它成为 11 个 html div 的纯响应式 css 网格。

enter image description here

<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 。

FIDDLE

我不得不调换框的顺序并向您的原始 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/

相关文章:

html - Internet Explorer 9 渐变过滤器切断子菜单

css - 如何使字体与其他字体相同?

css - 希望我的页面调整大小而不需要从东到西滚动

javascript - 将 DOM 中的一个表附加到另一个表。没有可用的类或 ID 的定位

jquery - 页面顶部的边距不正确?

javascript - html文件+d3.js脚本文件+在html文件中手动输入数据

html - 为什么在这种情况下需要负 margin 顶部

html - 覆盖在响应式视频之上

javascript - 加载后设置复选框状态

Javascript访问childNode