简体   繁体   English

使用CSS切换div上的位置?

[英]Switch places on div with CSS?

I'm buildinga site with CSS Media Queries for mobile and I need to switch places on 3 divs. 我正在建立一个带有CSS Media Queries移动版的网站,我需要在3个div上切换位置。

This is how it looks now : http://jsfiddle.net/snowman/3kZW2/ 现在是这样的: http : //jsfiddle.net/snowman/3kZW2/

And this is what I need : http://jsfiddle.net/snowman/7S7e9/ 这就是我需要的: http : //jsfiddle.net/snowman/7S7e9/

Is this possible with just changing the css of version 1? 仅更改版本1的CSS是否可行?

One way to achieve this is by setting widths on the DIVS and then using float right: 实现此目的的一种方法是在DIVS上设置宽度,然后使用向右浮动:

http://jsfiddle.net/wabJn/ http://jsfiddle.net/wabJn/

Here have a look http://jsfiddle.net/3kZW2/5/ 这里看看http://jsfiddle.net/3kZW2/5/

I used absolute positioning. 我使用绝对定位。 You may need to set the width and positioning as per your need, if div size changes. 如果div大小更改,则可能需要根据需要设置宽度和位置。 A more elegant solution would be to move the div2 above div1 in markup, here http://jsfiddle.net/3kZW2/4/ 一个更优雅的解决方案是将div2移到div1的标记上方,此处为http://jsfiddle.net/3kZW2/4/

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

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