简体   繁体   English

CSS响应浮动左右(更改哪个div在顶部)?

[英]CSS responsive float left and right (change which div goes on top)?

I'm working on this page: http://www.insidemarketblog.com/test-4/ 我正在此页面上工作: http : //www.insidemarketblog.com/test-4/

You'll see that the word "test" is in the div floated left, and the image is in the div floated right. 您会看到单词“ test”在div左上方浮动,图像在div右浮动。

If you resize it, you'll see the div floated left goes on top, and the div floated right goes below. 如果调整大小,则会看到向左浮动的div在顶部,向右浮动的div在下方。

How can you invert that order? 你怎么能颠倒顺序? So that the div floated left goes BELOW the div floated right. 因此,向左浮动的div低于向右浮动的div。 Nothing I do seems to work. 我似乎无济于事。

HTML: HTML:

<div class="main_header">
<div class="banner_left">
<p>test</p>
</div>
<div class="banner_right">
<img src="http://www.insidemarketblog.com/wp-content/uploads/2014/04/oz_main3.jpg">
</div>
</div>

CSS: CSS:

.main_header {
    background: none repeat scroll 0 0 #2B3443;
    border: 1px solid #FFFFFF;
    height: 300px;
    margin: 0 auto;
    overflow: hidden;
}
.banner_left {
    float: left;
}
.banner_right {
    float: right;
}

You can swap the order of the HTML tags to achieve the desired effect. 您可以交换HTML标记的顺序以获得所需的效果。

Change this: 更改此:

<div class="main_header">
<div class="banner_left">
<p>test</p>
</div>
<div class="banner_right">
<img src="http://www.insidemarketblog.com/wp-content/uploads/2014/04/oz_main3.jpg">
</div>
</div>

To this: 对此:

<div class="main_header">
<div class="banner_right">
<img src="http://www.insidemarketblog.com/wp-content/uploads/2014/04/oz_main3.jpg">
</div>
<div class="banner_left">
<p>test</p>
</div>
</div>

使它们都朝同一方向浮动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM