[英]Left floated div after the right floated div when small width
Example: http://jsfiddle.net/tkKth/ 示例: http : //jsfiddle.net/tkKth/
When I'm resizing my window (set .container {width:200px;}
), the left div appears after the right div. 调整窗口大小(设置
.container {width:200px;}
)时,左div出现在右div之后。 Is there a way to do this with css, when the divs left/right change their position in the html doc? 当div的左/右方向更改其在html文档中的位置时,是否可以使用CSS执行此操作? ->
<div class="left">Left div</div> <div class="right">Right div</div>
->
<div class="left">Left div</div> <div class="right">Right div</div>
Thanks 谢谢
6on your example http://jsfiddle.net/tkKth/ the right div is before the left 6在您的示例中http://jsfiddle.net/tkKth/右div在左之前
<div class="container">
<div class="right">Right div</div>
<div class="left">Left div
</div>
on your question it's the other way around 在你的问题上是相反的
<div class="container">
<div class="left">Left div</div>
<div class="right">Right div</div>
</div>
if the .container width is <= .left width & .right width, first in first served 如果.container width <= .left width&.right width,先到先得
if the left height is fixed (for the example 36px), you can use media queries with min-device-width: if the screen is below 600px, and add this for .right 如果左侧高度是固定的(例如36像素),则可以使用具有最小设备宽度的媒体查询:如果屏幕小于600像素,则将其添加为.right
top:36px; /* equivalent to .left height*/
position:absolute;
Some years later, flexbox is well supported, so this can be achieved with: 几年后,flexbox得到了很好的支持,因此可以通过以下方式实现:
.container {
display: flex;
}
.left {
order: 2;
}
.right {
order: 1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.