我一直在尋找幾個小時,但我找不到一種方法來將2個div彼此相鄰。 下面的例子工作正常時div的小於屏幕,但是當它們大於屏幕時,它們在彼此之下。 此外,我想同樣的類2頁:顯示2個div彼此相鄰,並在一起大於屏幕
- 1頁它們都適合在屏幕上,我想(右不是一個在左,一個)彼此相鄰顯示它們
- 其他頁面在一起它們比屏幕更大。 (側身滾動是沒有問題的)
拿這個例子:
<style>
.wrapper
{
border:1px solid Red;
display: inline-block;
}
.left
{
float:left;
color: Green;
border:1px solid Green;
}
.right
{
float:right;
color: Blue;
border:1px solid Blue;
}
</style>
<div class="wrapper">
<div class="left">
ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF
</div>
<div class="right">
ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF
</div>
<div class="clear" />
</div>
在實際設計中ASDF由大<table>
取代。 正如我上面所說,我一直在尋找幾個小時,但可以找到一個解決方案,所以我很抱歉,如果這已經問過。
感謝,它肯定欣慰地注意到,我的答案是支持[喬恩](http://stackoverflow.com/a/10244647/82548)(更好地解釋)答案=) – 2012-04-20 10:45:23