2016-03-13 73 views
1

我的CSS有問題 - 我有兩個div - 「section1」和「section2」。我希望它們並排顯示,但它們正如圖中所示顯示。有誰知道如何並排顯示它們?Div並排問題

issue

<div id="section1"> 
    <h1><London></h1> 
    <p>London is the capital city of England. It is the most populous city in the United Kingdom, 
with a metropolitan area of over 13 million inhabitants</p> 
    </div> 

    <div id="section2"> 
    <h2><London></h2> 
    <p1>London is the capital city of England. It is the most populous city in the United Kingdom, 
with a metropolitan area of over 13 million inhabitants</p> 
</div> 

</div> 

#section1 
{ 
float:center; 
padding:5px; 
background-color:lime; 
margin-left:20px; 
width:300px; 
} 

#section2 
{ 
float:right; 
background-color:lime; 
margin-left:10px; 
width:300px; 
} 

回答

2

你的float屬性應該是離開沒有中間和右側,並希望通過側移動他們一邊。

+0

你是對的 - 謝謝! –

1

您也可以添加清除:both;或清除:無;到你的CSS。這允許相對物體並排停放,或者被迫在現有物體下方。該命令在擁擠的頁面上效果最佳。