我已經遇到這個問題,其中我有分割如下: 堆疊的div水平/垂直基於設備/屏幕尺寸
這基本上是一個大問題的一小部分,並通過了解如何我正在計劃解決更大的問題。
如可以在上述圖像中可以看出我有兩個較小的部分,其中的每一個佔據較大的一個的高度的一半。但是,在平板電腦中,我希望它們並排。
這可以通過使用Bootstrap或其他框架輕鬆解決,但是我提出這個問題的動機是理解如何從頭開始完成這項工作的基本原理,更重要的是理解核心概念。
我在它一去,這是我嘗試JSFiddle
這裏是代碼,我想出了:
<div class="container">
<div class="largeImage">
<img src="http://lorempixel.com/745/292/sports/" alt="large">
</div>
<div class="smallImages">
<img src="http://lorempixel.com/214/145/sports/" alt="large">
<img src="http://lorempixel.com/214/145/sports/" alt="large">
</div>
.largeImage{
max-width:740px;
height:auto;
width:100%;
display:inline-block;
clear:both;
}
.largeImage img{
width:100%;
}
.smallImages{
background-color:lightgray;
display:inline-block;
max-width:210px;
}
.smallImages img{
width:100%;
height:auto;
}
.container{
background-color:whitesmoke ;
max-width:960px;
width:auto;
margin:0 auto;
}
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
body{
background-color:green;
}
.smallImages{
width:100%;
}
.smallImages img{
display:inline-block;
float:left;
clear:both;
}
.largeImage{
min-width:100% !important;
}
}
我不知道我是不是過於複雜的事情。但我希望有人能在這裏爲我澄清一下。
陳述我的問題: 如何堆疊上述圖像中描述的分區,而不使用任何框架,以及需要在我的嘗試中糾正哪些問題?
媒體查詢爲你的CSS這樣你就可以根據屏幕尺寸 – Pete
定位您的元素[下面是一個簡單的例子做你想要什麼(http://jsfiddle.net/p5L2F/) – Pete