Kann ich meine div-Blöcke neu anordnen, wenn ich das Fenster verkleinere? Zum Beispiel sollte das rote div vor dem blauen div erscheinen, wenn ich auf 0-770px width window verkleinere. Aber wenn das Fenster min ist. 771px sollte das blaue div vor dem roten div erscheinen.divs neu anordnen beim skalieren
Ich bin nicht sicher, dass es ohne Javascript möglich ist, aber eine Lösung ohne Javascript ist deffintly vorzuziehen.
Vielen Dank!
@charset "utf-8";
/* CSS Document */
#wrapper {
width: 1000px;
height: auto;
background-color: grey;
}
#boks-green {
width: 50%;
background-color: green;
height: 400px;
display: block;
float: left;
}
#boks-blue {
width: 50%;
background-color: deepskyblue;
height: 400px;
display: block;
position: relative;
float: left;
}
#boks-red {
width: 50%;
background-color: red;
height: 400px;
display: block;
position: relative;
float: left;
}
#boks-purple {
width: 50%;
background-color: purple;
height: 400px;
display: block;
position: relative;
float: left;
}
@media only screen and (max-width: 770px) {
#boks-green {
width: 100%;
background-color: green;
height: 400px;
display: block;
float: left;
}
#boks-blue {
width: 100%;
background-color: deepskyblue;
height: 400px;
display: block;
position: relative;
float: left;
}
#boks-red {
width: 100%;
background-color: red;
height: 400px;
display: block;
position: relative;
float: left;
}
#boks-purple {
width: 100%;
background-color: purple;
height: 400px;
display: block;
position: relative;
float: left;
}
}
<div id="wrapper">
<div id="boks-green">
</div>
<div id="boks-blue">
</div>
<div id="boks-red">
</div>
<div id="boks-purple">
</div>
</div>
Dies ist mit [flexbox and order] möglich (https://css-tricks.com/snippets/css/a-guide-to-flexbox/#article-header-id-9). – jrenk
Mögliches Duplikat von [Position des Swaps DIV nur mit CSS] (https://stackoverflow.com/questions/17455811/swap-div-position-with-css-only) – rblarsen
Mit Float und bekannter Höhe können Sie mit dem Block spielen Formatieren Kontext und tauschen rote und blaue Kästchen https://codepen.io/anon/pen/dzNBdL klar und Überlauf –