css - 设计灵活的页面布局

标签 css css-float

先看paint中准备好的图片。

我想设计一个灵活的页面,其中包含这种类型的四部分。因此更改监视器屏幕或浏览器大小会自动调整窗口大小。这所有 4 个框应适合 100% 浏览器屏幕和任何显示器尺寸,并避免滚动条出现。那么谁能告诉我如何在 css 样式表中对其进行编码。

这是我的代码。 HTML:

<div id="bottomleft">
</div>

<div id="topleft">
</div>

<div id="topright">
</div>

<div id="bottomright">
</div>

</div>
</body>

CSS:

    *
    {
    margin: 0;
    padding: 0;
    }
    #wrapper
    {
    margin: 0px auto;
    height: 100%;
    width: 100%;
    }
    #bottomleft
    {
    position:relative;
    height: 50%;
    width: 50%;
    border: 1px solid black;
    float: left;
    }
    #topleft
    {
    position:relative;
    height: 50%;
    width: 50%;
    border: 1px solid black;
    float: right;
    }
    #topright
    {
    position:relative;
    height: 50%;
    width: 50%;
    border: 1px solid black;
    float: left;
    }
    #bottomright
    {
    position:relative;
    height: 50%;
    width: 50%;
    border: 1px solid black;
    float: right;
    }

最佳答案

Demo

HI 现在在 css 中定义你的 body, html height 100%;

并在您的 id 中定义 box-sizing

body, html{
height:100%;
}
#bottomleft, #bottomright, #topright, #topleft{
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}

Demo

关于css - 设计灵活的页面布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12812790/

相关文章:

html - 使进度条动态更改宽度以适应容器其余部分的大小

css - 如何使用 CSS 创建向下箭头?

jquery - jQueryUI 图标中是否存在 CSS 错误

jquery - 在 IE7 中为 jquery ganttView 使用 css

javascript - float 重定位的 CSS 过渡

css - 如何使用 CSS 将元素样式定义为位于另一个元素之上?为什么在我的情况下 z-index 无效?

html - 向左浮动 span 和 div 不能按照我想要的方式工作

html - 如何实现这种网格布局?

html - 绝对定位的元素不会被其容器剪裁

css - 如何防止两个div中的 float 内容重叠?