代码之家  ›  专栏  ›  技术社区  ›  Moon

CSS:Div定位…帮助

  •  0
  • Moon  · 技术社区  · 14 年前

    看看这个 Code

    2 回复  |  直到 14 年前
        1
  •  0
  •   CuriousCurmudgeon    14 年前

    向左和向右浮动div并清除页脚。您还需要调整左div和右div的宽度,使它们适合同一行。

    #left
    {
        position:static;
        width: 40%;
        height: 50px;
        margin-top: 10px;
        margin-right: 10px;
        background: #111111;
        border: solid 3px #ff0000; 
        float: left;
    }
    
    #right
    {
        position:static;
        width: 40%;
        height: 50px;
        margin-top: 10px;
        margin-right: 10px;
        background: #111111;
        border: solid 3px #ff0000;
        float: left;
    }
    
    #footer
    {
        position: static;
        width   : 100%;
        height  : 50px;
        margin-top: 10px;
    
        background: #111111;
        border: solid 3px #ff0000;
        text-align: center;
        clear: both;
    }
    
        2
  •  1
  •   Brandon Frohbieter    14 年前
    <div><div style="float:left">a</div> <div style="float:left">b</div></div>
    <div style="clear:both"></div>