在正常窗口中,水平排列<div>
。一旦窗口尺寸變小,垂直堆疊<div>
。它們顯示在附圖中。如何根據幀大小定位div位置?
對於我做了塊和包裝盒。盒子在座內。
.blocks {
display: block;
margin: 0 auto;
width: 85%;
min-height: 420px;
}
.box1,
.box2,
.box3 {
width: 33.333%;
height: 100%;
vertical-align: top;
display: inline-block;
zoom: 1;
text-align: center;
}
.blocks .box1 img,
.blocks .box2 img,
.blocks .box3 img {
max-width: 100%;
height auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="blocks">
<div class="col-sm-4 col-xs-4 box1 p_1" style="background-color: #ccffe5;">
<h1>BOX 1</h1>
</div>
<div class="col-sm-4 col-xs-4 box2 p_1" style="background-color: #ffffcc;">
<h1>BOX 2</h1>
</div>
<div class="col-sm-4 col-xs-4 box3 p_1" style="background-color: #ccffe5;">
<h1>BOX 3</h1>
</div>
</div>
這樣安排,它們總是水平地佈置。
如何根據窗口大小水平和垂直排列它們?
編輯:
你的意思是重新安排其他命令 –
箱子@ PeterWilson,是的。 \t 請在預覽中看到此處。 wordpress.org/themes/skt-spa。一旦幀變得小於極限,尺寸就會從小到大動態變化。然後將其定位在頁面的水平中心。如何做到這一點?我們的方法堅持留下的問題。 – batuman