Hallo zusammen,
ich teste gerade wie ich einen Stundenplan responsive gestalten kann und habe dazu die DIV's mit Flexbox gestaltet. Leider funktioniert der Befehl für die Media Queries nicht. Aber warum? Wie kann ich jedem zweiten Child einen farbigen Background geben.
Den Code habe ich beigefügt.
HTML
HTML
<!DOCTYPE html>
<html lang="den">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Stundenplan</title>
</head>
<body>
<div class="wrapper">
<div class="flexbox-row">
<div class="flex-item">
<p>Montag</p>
</div>
<div class=".flex-item:nth-child(1)">
<p>07:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(2)">
<p>08:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(3)">
<p>09:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(4)">
<p>10:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(5)">
<p>11:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(6)">
<p>12:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(7)">
<p>13:00<br> - </p>
</div>
<div class=".flex-item:nth-child(8)">
<p>14:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(9)">
<p>15:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(10)">
<p>16:00 <br> Workout</p>
</div>
</div>
<div class="flexbox-row">
<div class="flex-item">
<p>Dienstag</p>
</div>
<div class=".flex-item:nth-child(1)">
<p>07:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(2)">
<p>08:00<br> - </p>
</div>
<div class=".flex-item:nth-child(3)">
<p>09:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(4)">
<p>10:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(5)">
<p>11:00<br> - </p>
</div>
<div class=".flex-item:nth-child(6)">
<p>12:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(7)">
<p>13:00<br> - </p>
</div>
<div class=".flex-item:nth-child(8)">
<p>14:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(9)">
<p>15:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(10)">
<p>16:00 <br> Workout</p>
</div>
</div>
<div class="flexbox-row">
<div class="flex-item">
<p>Mittwoch</p>
</div>
<div class=".flex-item:nth-child(1)">
<p>07:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(2)">
<p>08:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(3)">
<p>09:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(4)">
<p>10:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(5)">
<p>11:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(6)">
<p>12:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(7)">
<p>13:00<br> - </p>
</div>
<div class=".flex-item:nth-child(8)">
<p>14:00 <br> Rückenschule</p>
</div>
<div class=".flex-item:nth-child(9)">
<p>15:00 <br> Workout</p>
</div>
<div class=".flex-item:nth-child(10)">
<p>16:00 <br> Workout</p>
</div>
</div>
</div>
</body>
</html>
CSS
.wrapper{
width:90%;
margin: 0 auto;
}
.flexbox-row {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-around;
align-items: flex-start;
align-content: center;
}
.flexbox-item {
flex: 0 1 auto;
background-color: lightblue;
}
.flex-item:nth-child(1) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(2) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(3) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(4) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(5) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(6) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(7) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(8) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(9) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item:nth-child(10) {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
/* Media Queries */
@media (max-device-width: 800px) { /* Breite entspricht genau 800 Pixel */
.wrapper{
width: 100%;
}
.flexbox-row {
display: flex;
flex-direction: column;
padding: 0 2%;
}
}
Alles anzeigen