CSS Media Query

Mit Media Query kann das Seitelyout automatisch an die Bildschirmgröße angepasst werden, damit kann eine Seite für Mobil und Desktop optimiert werden. Sprich mit Media Query kann das Layout an den Bildschirm angepasst werden. Die wichtigsten Parameter sind min-width und max-width.

min-width

Mit min-width kann das CSS bei einer mindestbreite geändert werden.

 body {
        background-color: white;
}
@media screen and (min-width: 480px) {
    body {
        background-color: black;
    }
}

Demo öffnen

max-width

Mit max-width kann bis zu einer Maximalgröße CSS Eigenschaften ausgespielt werden.

 body {
        background-color: white;
}
@media screen and (max-width: 480px) {
    body {
        background-color: black;
    }
}

Demo öffnen

beide kombinieren

Mit and können beide Eigenschaften kombiniert werden.

 body {
        background-color: white;
}
@media (min-width: 0px) and (max-width: 400px){
    body {
        background-color: #021ffd;
    }
}
@media (min-width: 400px) and (max-width: 600px){
    body {
        background-color: #fd0202;
    }
}

Demo öffnen


wallpaper-1019588
Die richtige Matratze für erholsamen Schlaf
wallpaper-1019588
Red Bull League of Its Own: E-Sport-Spektakel im SAP Garden restlos ausverkauft
wallpaper-1019588
Wie super sind Superfoods wirklich?
wallpaper-1019588
Schreiben an der Algarve – Ein ungewöhnliches Weihnachtsgeschenk für sich selbst und für andere
wallpaper-1019588
Die niederländische Küste entdecken: ein entspannter Urlaub am Meer