我正在使用兩個部門(兩個高度設置爲自動)。重新排序Div像源重新排序
現在,在移動視圖中,我希望左側視圖爲100%寬度,底部和右側視圖爲100%並位於頂部;怎麼能做到這一點?
如果我將margin-left:100%
設置爲左側而margin-left:-100% to right
則設置爲離屏,水平滾動條顯示在瀏覽器中。
這裏是 FIDDLE
我正在使用兩個部門(兩個高度設置爲自動)。重新排序Div像源重新排序
現在,在移動視圖中,我希望左側視圖爲100%寬度,底部和右側視圖爲100%並位於頂部;怎麼能做到這一點?
如果我將margin-left:100%
設置爲左側而margin-left:-100% to right
則設置爲離屏,水平滾動條顯示在瀏覽器中。
這裏是 FIDDLE
下面是使用完全相同的HTML的例子。只有CSS正在改變,這可以通過媒體查詢完成。
html, body{ height:100%; width:100%; margin:0; padding:0 }
#red{
background:red; height:40%; width:50%; float:left;
}
#yellow{
background:yellow; height:40%; width:50%; float:left;
}
<div id="yellow"></div><div id="red"></div>
html, body{ height:100%; width:100%; margin:0; padding:0 }
#red{
background:red; height:40%; width:100%;
}
#yellow{
background:yellow; height:40%; width:100%;
}
<div id="yellow"></div><div id="red"></div>
編輯:使用,如果你希望它們翻轉下面的代碼。
html, body{ height:100%; width:100%; margin:0; padding:0 }
#red{
background:red; height:40%; width:100%;
position:relative;
top:-40%;
}
#yellow{
background:yellow; height:40%; width:100%;
position:relative;
top:40%;
}
<div id="yellow"></div><div id="red"></div>
怎麼辦,如果我在頂部,左邊底部 – 2015-04-05 02:58:04
我更新了我的答案。讓我知道這是否適合你。 – 2015-04-05 03:04:09
謝謝,但如果它的響應和我不知道高度。我的意思是它的自動高度就像在框架中一樣? – 2015-04-05 03:11:50
您是否嘗試過使用'位置:relative'? – 2015-04-05 02:49:50
不,不工作.. – 2015-04-05 02:53:29
仍然divs與右側水平滾動條 – 2015-04-05 02:53:43