2010-10-27 62 views

回答

0

浮動左邊和右邊的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; 
} 
+0

我沒有對齊,但現在我的邊界並不在一條直線上排列的http:// jsfiddle.net/ayqyn/ – Moon 2010-10-27 18:22:23

+0

您正在將標題的寬度設置爲100%,即300px。當你添加邊框時,它會被添加到這個div的外部。這意味着您的標題的實際寬度爲300 + 2 * 3 = 306px。您需要決定是否要在容器內放置邊框,並相應地調整寬度。 – CuriousCurmudgeon 2010-10-27 18:42:12

1
<div><div style="float:left">a</div> <div style="float:left">b</div></div> 
<div style="clear:both"></div> 
+0

我這樣做,但現在我的邊界並不在一條直線上http://jsfiddle.net/ayqyn/ – Moon 2010-10-27 18:23:39