Jeder Webentwickler steht heute vor der Herausforderung attraktive Webdesigns (nicht wie das von webconsul.de
) zu entwickeln und dabei alle möglichen Geräte zu berücksichtigen.
Von Desktops, über Laptops, iPads, iPhones, beliebige Smartphones (bspw. mit Android) bis zu ultrabreiten Bildschirmscreens
Das Beispiel zum Anschauen findet ihr hier: Responsive Design CSS Check.
Die Browser sowohl von Desktop-/PC-/Laptopumgebungen sowie mobile Geräte können diese Unterscheidung mittlerweile gut durchführen.
Die Unterscheidung basiert dabei immer auf der Bildschirmgröße und sieht folgendermaßen als Code aus:
Smartphones (portrait and landscape)
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
body{background-color:yellow;}
h1#smartphone{display:block}
}
Smartphones (landscape)
@media only screen
and (min-width : 321px)
and (max-width : 480px) {
/* Styles */
body{background-color:lightyellow;}
h1#smartphonelandscape{display:block}
}
Smartphones (portrait)
@media only screen
and (max-width : 320px) {
/* Styles */
body{background-color:orange;}
h1#smartphoneportrait{display:block}
}
iPads (portrait and landscape)
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
body{background-color:green;}
h1#ipads{display:block}
}
iPads (landscape)
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
body{background-color:lightgreen;}
h1#ipadlandscape{display:block}
}
iPads (portrait)
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
body{background-color:darkgreen;}
h1#ipadportrait{display:block}
}
Desktops and laptops
@media only screen
and (min-width : 1224px) {
/* Styles */
body{background-color:blue;}
h1#desktop{display:block}
}
Large screens
@media only screen
and (min-width : 1824px) {
/* Styles */
body{background-color:lightblue;}
h1#largescreens{display:block}
}
iPhone 4
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
body{background-color:red;}
h1#iphone4{display:block}
}
Im jeweiligen Block unter /* Styles */ müsst ihr natürlich noch die eigenen Werte für das jeweilige Layout und Gerät ergänzen.
Im Normalfall empfehle ich einen generellen und vorgelagerten allgemeinen Designblock und dann für das spezielle Gerät nur noch Größenanpassungen der jeweiligen DIVs.