html - 在html中将div划分为左,右,下

标签 html css

这是我想要的布局,

enter image description here

我用代码做了一些,但我不确定之后该怎么做。

[html]

  <div id="content">
        <div id="left">left</div>
        <div id="right">right</div>
        <div id="bottom">bottom</div>    
    </div>

[CSS]

  #content{
        /* the width in here will be changed 
        width: this requirment will be changed
        i dont' want to type my left, right content static
        is there a way? */
    }
    #left{
        float:left;
        width: 50px;
    }
    #right{
        float:left;
        width: 50px;
    }
    #bottom{
        /*what do i have to do in here?
        float:*/
    }

最佳答案

你可以这样做:

#bottom 上设置clear:both。将 width:50% 添加到 #left/#right

最后,指定元素的边框并添加 box-sizing 以便将边框包含在元素的宽度计算中。

jsFiddle example

#content {
    border:1px solid black;
}
#content > div {
    height:100px;
    box-sizing:border-box;
    -moz-box-sizing:border-box;
}
#left {
    float:left;
    width: 50%;
    border-right:1px solid black;
}
#right {
    float:right;
    width: 50%;
}
#bottom {
    border-top:1px solid black;
    clear: both;
}

关于html - 在html中将div划分为左,右,下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20533971/

相关文章:

php - 使用 switch 元素更新 DB 值

javascript - PHP 中使用多个复选框进行过滤

html - css 色调变小

html - 在VB2010中有什么简单的方法可以为单个单词添加颜色?

javascript - 如何组织我的网页内容?

html - 使用 CSS 设置箭头的永久位置,而不影响表格单元格中的文本对齐

css - 如何检索应用于 flex UIComponent 的所有样式属性?

javascript - 隐藏点击表上的行

php - 在 HTML - PHP Web 应用程序上使用 SASS 实现调色板?

html - 没有侧面导航时顶部导航调整大小