我有三个3子div,分别为span2,span7和span3。当我的浏览器宽度低于763px时,我希望它的顺序为span2,span3和span7。我将如何通过CSS进行此操作?
这是我的初始代码:
<div class="row-fluid">
<div class="span2">
</div>
<div class="span7">
</div>
<div class="span3">
</div>
</div>
答案 0 :(得分:3)
您可以使用flexible boxes布局和flex order来实现这一目标:
JSFiddle - DEMO
.row-fluid > div {
width: 100px;
height: 100px;
border: 1px solid red;
}
@media (max-width: 763px) {
.row-fluid {
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.span2 {
order: 1;
}
.span7 {
order: 3;
}
.span3 {
order: 2;
}
}
<div class="row-fluid">
<div class="span2">span2</div>
<div class="span7">span7</div>
<div class="span3">span3</div>
</div>