2013-12-12 77 views
-2

我有2個div。其實在窗的全寬,它就像Inter在窗口大小變化時更改div的位置

enter image description here

而當窗口重新調整大小,我得到了 enter image description here

但實際上,我要像 enter image description here

如何輸出我重寫我的CSS(或任何jQuery爲此)爲了得到這個把

<div class="wrap"> 
<div class="right"></div> 
<div class="left"></div> 

</div> 
.wrap {width: 85%; margin: auto; overflow: hidden;} 
.left {float: right; height: 250px; width: 49%; background: pink;} 
    .right {float: left; height: 250px; margin-bottom: 10px; width: 49%;} 
    .right {background: green;} 
    @media all and (max-width: 400px) { 
    .left, .right {float: none; margin-bottom: 5px; height: 200px;} 
     } 

http://jsfiddle.net/deKMy/1/

回答

1

我已經更新了小提琴 - http://jsfiddle.net/deKMy/2/

<div class="wrap"> 
    <div class="right"></div> 
    <div class="left"></div> 

</div> 


.wrap {width: 85%; margin: auto; overflow: hidden;} 
.left {float: left; height: 250px; width: 49%; background: green;} 
.right {float: right; height: 250px; margin-bottom: 10px; width: 49%;} 
.right {background: pink;} 
@media all and (max-width: 400px) { 
    .left, .right {float: none; margin-bottom: 5px; height: 200px;} 
} 
1

只是交換了兩個div:

<div class="wrap"> 
    <div class="left"></div> 
    <div class="right top"></div> 
</div> 

.wrap {width: 85%; margin: auto; overflow: hidden;} 
.left {float: right; height: 250px; width: 49%; background: pink;} 
.right {float: left; height: 250px; margin-bottom: 10px; width: 49%;} 
.right.top {background: green;} 
@media all and (max-width: 400px) { 
    .left, .right {float: none; margin-bottom: 5px; height: 200px;} 
} 
+0

如果你不看的jsfiddle代碼。 http://jsfiddle.net/2w7D7/ – KungWaz

1

變化的.css這樣。

.wrap {width: 85%; margin: auto; overflow: hidden;} 
.left {float: left; height: 250px; width: 49%; background: pink;} 
.right {float: right; height: 250px; margin-bottom: 10px; width: 49%;} 
.right.top {background: green;} 
@media all and (max-width: 400px) { 
    .left, .right {float: none; margin-bottom: 5px; height: 200px;} 
} 

http://jsfiddle.net/ayiem999/XgLC5/

+0

嘆息..首先評論但其他人得到接受..hahaha – airi

相關問題