SlideShare ist ein Scribd-Unternehmen logo
Michael Jendryschik | itemis AG CSS Media Queries Auf Browser und Geräte reagieren
Michael Jendryschik Konzipiert und entwickelt Websites, schreibt und spricht darüber http://jendryschik.de Leiter Webentwicklung http://www.itemis.de Webkraut http://www.webkrauts.de
Es gibt verschiedene Möglichkeiten, den Geltungsbereich von CSS auf bestimmte Medien einzuschränken.
aural  für Sprachbrowser
braille  für Geräte mit Braillezeile
embossed  für Brailledrucker
handheld  für Handcomputer und Mobiltelefone
print  für Drucker
projection  für Projektoren
screen  für Monitore
tty  für Ausgabemedien mit Festbreitenschrift
tv  für Fernseher
CSS-Medientypen  Typ Medium all alle Geräte aural Sprachbrowser braille Ausgabegeräte mit Braillezeile embossed Brailledrucker handheld Handcomputer und Mobiltelefone print Drucker projection Projektion screen Computermonitore tty Ausgabemedien mit Festbreitenschrift tv Fernseher
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot;  media=&quot;screen&quot;  /> @import url(&quot;style.css&quot;)  screen ;  @media print { div#header, div#sidebar, div#footer { display: none; } }
Mit CSS Media Queries ist es möglich, die Einbindung von CSS davon abhängig zu machen, ob ein Medium oder Ausgabegerät bestimmte Merkmale aufweist oder nicht.
Microsoft IE Test Drive
@media (min-width: 950px) { /* Regeln für breite Browserfenster */ } @media (min-width: 450px)   and (max-width: 950px) {    /* Regeln für Netbooks */ } @media (max-width: 450px) { /* Regeln für mobile Geräte */ }
A List Apart Artikelbeispiel
@media screen and (max-width: 600px) { .mast, .intro, .main, .footer { float: none; width: auto; } }
Jon Hicks
@media screen and (max-width: 500px) { … } @media screen and (max-width: 800px) { … } @media screen and (min-width: 1024px) { … } @media handheld and (max-device-width: 480px), screen and (max-device-width: 480px), screen and (max-width: 600px) { … } @media screen and (min-width: 920px) { … } @media screen and (min-width: 1350px) { … } @media screen and (min-width: 1500px) { … } @media only screen and (max-device-width: 480px) { … } @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { … }
kleines iPhone-Beispiel <ol> <li class=&quot;ready&quot;>Fertig?</li> <li class=&quot;go&quot;>Los!</li> </ol>
kleines iPhone-Beispiel @media only screen  and (-webkit-min-device-pixel-ratio: 2)  and (orientation: landscape) { body  { background-color: yellow; } li.go { display: none; } }
kleines iPhone-Beispiel @media only screen  and (-webkit-min-device-pixel-ratio: 2)  and (orientation: portrait) { body {   color: white;   background-color: green; } li.ready { display: none; } }
 
CSS Media Queries Grundlagen und Syntax
Media Queries sind logische Ausdrücke, die die Angabe von Medientypen und bestimmten Medienmerkmalen miteinander verknüpfen.
Bezeichnung Beispiel Media Query screen and (max-width: 300px) Medientyp screen   and (max-width: 300px) Verknüpfung screen  and   (max-width: 300px) Ausdruck screen and ( max-width: 300px ) Merkmal screen and ( max-width : 300px) Wert screen and (max-width:  300px )
Das Schlüsselwort  and  drückt ein logisches Und aus. screen  and  (max-width: 300px) (min-width: 450px) and  (max-width: 950px)
Ein Komma steht für ein logisches Oder. @import url(&quot;style.css&quot;) screen ,  projection; <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot;screen and (min-width: 800px) ,   projection and (min-width: 800px)&quot; />
Das Schlüsselwort  not  steht für eine logische Negation. <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot; not  screen and (color)&quot; />
Das Schlüsselwort  only  ist ein Workaround für veraltete Browser, die mit Media Queries nicht umzugehen wissen <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot; only  screen and (color)&quot; />
CSS Media Queries Medienmerkmale
Breite und Höhe Merkmal min/max Beschreibung width Ja Breite der Anzeigefläche height Ja Höhe der Anzeigefläche device-width Ja Breite des Geräts device-height Ja Höhe des Geräts
Viewport mindestens 500px hoch? <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;vertical-align.css&quot; media=&quot;screen and ( min-height: 500px )&quot; />
Smartphone? @media only screen and ( min-device-width: 320px )  and ( max-device-width: 480px ) { … }
Gerät- und Viewportbreite Achtung! Breite des Viewports ist häufig größer als die des Geräts selbst <meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;> Weitere Informationen: http://www.quirksmode.org/blog/archives/2010/09/combining_meta.html
Seitenverhältnis und Ausrichtung Merkmal min/max Beschreibung aspect-ratio Ja Verhältnis der Merkmale  width  und  height device-aspect-ratio Ja Verhältnis der Merkmale  device-width  und  device-height orientation Nein Ausrichtung des Geräts
Seitenverhältnis 16:9? @media only screen   and ( device-aspect-ratio: 16/9 ) { … } @media screen and ( device-aspect-ratio: 1280/720 ) { … }
Horizontale oder vertikale Ausrichtung eines iPad? <link … href=&quot;ipad-portrait.css&quot; media=&quot;(min-device-width: 768px) and (max-device-width: 1024px) and ( orientation: portrait )&quot; /> <link … href=&quot;ipad-landscape.css&quot; media=&quot;(min-device-width: 768px) and (max-device-width: 1024px) and ( orientation: landscape )&quot; />
Farbmerkmale Merkmal min/max Beschreibung color Ja Farbtiefe des Geräts color-index Ja Anzahl der Einträge in der Farb-Lookup-Tabelle des Geräts monochrome Ja Anzahl der Bits pro Pixel im Bildspeicher eines einfarbigen Geräts
Schwarzweiß- oder Farbdrucker? <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;print-color.css&quot; media=&quot;print and ( color )&quot; /> <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;print-monochrome.css&quot; media=&quot;print and ( monochrome )&quot; />
 
iPhone4? <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/retina.css&quot; media=&quot;only screen and ( -webkit-min-device-pixel-ratio: 2 )&quot; />
Browserkompatibilität
 
Fragen?
Michael Jendryschik [email_address] [email_address] twitter.com/jendryschik www.facebook.com/jendryschik www.xing.com/profile/Michael_Jendryschik
Beispiele http://ie.microsoft.com/testdrive/HTML5/85CSS3_MediaQueries/Default.html http://www.alistapart.com/d/responsive-web-design/ex/ex-site-larger.html http://hicksdesign.co.uk/ http://files.jendryschik.de/examples/wtc2010/mq.html
Abbildungsnachweis http://www.digitale-chancen.de/transfer/assets/468.jpg http://ceipntrasradelapiedad.files.wordpress.com/2010/03/braille.jpg http://gadgets.boingboing.net/Palm-Pre-Disassembled.jpg http://upload.wikimedia.org/wikipedia/commons/d/dc/Westermann_Druckerei_1890.png http://www.infocus.rbt-pressroom.eu/de/download/der-heimkino-projektor-sp8602-kommt-vielen-hochleistungsfhigen-eigenschaften-auf-den-markt-4.jpg http://upload.wikimedia.org/wikipedia/commons/2/2c/Monitor_in_gutter.jpg http://cmsdata.iucn.org/img/original/iberian_lynx_by_antonio_rivas.jpg http://www.comcast.com/MediaLibrary/1/1/About/PressRoom/Images/LogoAndMediaLibrary/Photography/CableNetworks/Teletubbies-Group2.jpg http://www.audiobooks.at/images/cover/europa/DDF_132_CD.jpg http://www.pm.ruhr-uni-bochum.de/imperia/md/images/pressestelle/einstein.jpg http://img2.fengniao.com/product/28/473/ceOnyLQihT8xg.jpg http://www.apple.com/iphone/ http://wallpapers-diq.net/wallpapers/30/Firefox%2C_The_Browser%2C_Reloaded.jpg

Weitere ähnliche Inhalte

PPT
CSS Media Queries (WordCamp 2010)
PPT
Rethink Christmas Slowdown
PPT
ενέργεια στ 11
PPT
KEY
0503 天下雜誌書香花園 1人.com vs. fb社交圖譜的應用 shirley
PPT
Wine Conversation 081209
PPT
Propaganda
PPT
Presentation On Edf 2005
CSS Media Queries (WordCamp 2010)
Rethink Christmas Slowdown
ενέργεια στ 11
0503 天下雜誌書香花園 1人.com vs. fb社交圖譜的應用 shirley
Wine Conversation 081209
Propaganda
Presentation On Edf 2005

Andere mochten auch (20)

PPT
Immobiliare.it: Milano e le sue prospettive di sviluppo immobiliare
PPT
Sos gioco
PPT
Business Dynamics I Acknowledging Sources
PPT
Presentation eeep comiclab
PPT
PPT
ενέργεια στ 2
PPTX
Slide quiz #1
PDF
Buurtkracht presentatie proven nov 2013
PPT
2 κριτήριο γλώσσας
PPT
Homer donut odyssey
PPT
Periodic Trends
PDF
Examples pp documentation
PPT
Nike
PPT
Το πετρέλαιο ως πρώτη ύλη ΣΤ ΦΕ6
PDF
Hnw coevent 31 mei 2011
PPT
Periodic Table E Config
PPT
Writing A Lab Report- Komperda
PPTX
Engineering entepreneurship fall 2012
PPT
οδυσσέας ελύτης
PPS
Arron and Marci
Immobiliare.it: Milano e le sue prospettive di sviluppo immobiliare
Sos gioco
Business Dynamics I Acknowledging Sources
Presentation eeep comiclab
ενέργεια στ 2
Slide quiz #1
Buurtkracht presentatie proven nov 2013
2 κριτήριο γλώσσας
Homer donut odyssey
Periodic Trends
Examples pp documentation
Nike
Το πετρέλαιο ως πρώτη ύλη ΣΤ ΦΕ6
Hnw coevent 31 mei 2011
Periodic Table E Config
Writing A Lab Report- Komperda
Engineering entepreneurship fall 2012
οδυσσέας ελύτης
Arron and Marci
Anzeige

Ähnlich wie CSS Media Queries (WebTech Conference 2010) (17)

PDF
CSS3 Media Queries
PDF
Webseiten für mobile Geräte - M-Days - Frankfurt 27.01.2011
PDF
Responsive Webdesign - Unter der Haube
PDF
Was nicht passt wird responsive gemacht - Extended Edition
PDF
121127 SouperTuesday "Responsive Webdesign"
PDF
Responsive Web Design für Mobilgeräte mit Drupal
KEY
Responsive Web Design - Ein Überblick
PPTX
Entwicklercamp responive web design
PDF
Was nicht passt wird responsive gemacht - Conference Edition
PDF
Webstandards auf dem Weg zu Standards im Mobilen Bereich
PDF
Layout Frameworks im professionellen Webdesign
PPTX
There and back again - Responsive Webdesign mit WordPress
PDF
Size Matters. Responsive-Design-Lösungen mit denkwerk (2013)
PDF
Responsive Web Design
PDF
Praktikum in Frontendentwicklung - Session1
PDF
Responsive Webdesign
PDF
Mobile Web Apps
CSS3 Media Queries
Webseiten für mobile Geräte - M-Days - Frankfurt 27.01.2011
Responsive Webdesign - Unter der Haube
Was nicht passt wird responsive gemacht - Extended Edition
121127 SouperTuesday "Responsive Webdesign"
Responsive Web Design für Mobilgeräte mit Drupal
Responsive Web Design - Ein Überblick
Entwicklercamp responive web design
Was nicht passt wird responsive gemacht - Conference Edition
Webstandards auf dem Weg zu Standards im Mobilen Bereich
Layout Frameworks im professionellen Webdesign
There and back again - Responsive Webdesign mit WordPress
Size Matters. Responsive-Design-Lösungen mit denkwerk (2013)
Responsive Web Design
Praktikum in Frontendentwicklung - Session1
Responsive Webdesign
Mobile Web Apps
Anzeige

Mehr von Michael Jendryschik (6)

PPTX
Entwicklungen in Spielen als Innovationstreiber für Usability
PDF
Von der Nutzungsanforderung bis zur formalen Softwarespezifikation – Modellie...
PDF
Personas im Usability Engineering
ODP
HTML5: Einblick, Überblick, Ausblick
ODP
Websemantik: Die nächsten Schritte
PPT
6 Beispiele für die nützliche Anwendung von Mikroformaten
Entwicklungen in Spielen als Innovationstreiber für Usability
Von der Nutzungsanforderung bis zur formalen Softwarespezifikation – Modellie...
Personas im Usability Engineering
HTML5: Einblick, Überblick, Ausblick
Websemantik: Die nächsten Schritte
6 Beispiele für die nützliche Anwendung von Mikroformaten

CSS Media Queries (WebTech Conference 2010)

  • 1. Michael Jendryschik | itemis AG CSS Media Queries Auf Browser und Geräte reagieren
  • 2. Michael Jendryschik Konzipiert und entwickelt Websites, schreibt und spricht darüber http://jendryschik.de Leiter Webentwicklung http://www.itemis.de Webkraut http://www.webkrauts.de
  • 3. Es gibt verschiedene Möglichkeiten, den Geltungsbereich von CSS auf bestimmte Medien einzuschränken.
  • 4. aural für Sprachbrowser
  • 5. braille für Geräte mit Braillezeile
  • 6. embossed für Brailledrucker
  • 7. handheld für Handcomputer und Mobiltelefone
  • 8. print für Drucker
  • 9. projection für Projektoren
  • 10. screen für Monitore
  • 11. tty für Ausgabemedien mit Festbreitenschrift
  • 12. tv für Fernseher
  • 13. CSS-Medientypen Typ Medium all alle Geräte aural Sprachbrowser braille Ausgabegeräte mit Braillezeile embossed Brailledrucker handheld Handcomputer und Mobiltelefone print Drucker projection Projektion screen Computermonitore tty Ausgabemedien mit Festbreitenschrift tv Fernseher
  • 14. <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot;screen&quot; /> @import url(&quot;style.css&quot;) screen ; @media print { div#header, div#sidebar, div#footer { display: none; } }
  • 15. Mit CSS Media Queries ist es möglich, die Einbindung von CSS davon abhängig zu machen, ob ein Medium oder Ausgabegerät bestimmte Merkmale aufweist oder nicht.
  • 17. @media (min-width: 950px) { /* Regeln für breite Browserfenster */ } @media (min-width: 450px) and (max-width: 950px) {   /* Regeln für Netbooks */ } @media (max-width: 450px) { /* Regeln für mobile Geräte */ }
  • 18. A List Apart Artikelbeispiel
  • 19. @media screen and (max-width: 600px) { .mast, .intro, .main, .footer { float: none; width: auto; } }
  • 21. @media screen and (max-width: 500px) { … } @media screen and (max-width: 800px) { … } @media screen and (min-width: 1024px) { … } @media handheld and (max-device-width: 480px), screen and (max-device-width: 480px), screen and (max-width: 600px) { … } @media screen and (min-width: 920px) { … } @media screen and (min-width: 1350px) { … } @media screen and (min-width: 1500px) { … } @media only screen and (max-device-width: 480px) { … } @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { … }
  • 22. kleines iPhone-Beispiel <ol> <li class=&quot;ready&quot;>Fertig?</li> <li class=&quot;go&quot;>Los!</li> </ol>
  • 23. kleines iPhone-Beispiel @media only screen and (-webkit-min-device-pixel-ratio: 2) and (orientation: landscape) { body { background-color: yellow; } li.go { display: none; } }
  • 24. kleines iPhone-Beispiel @media only screen and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) { body { color: white; background-color: green; } li.ready { display: none; } }
  • 25.  
  • 26. CSS Media Queries Grundlagen und Syntax
  • 27. Media Queries sind logische Ausdrücke, die die Angabe von Medientypen und bestimmten Medienmerkmalen miteinander verknüpfen.
  • 28. Bezeichnung Beispiel Media Query screen and (max-width: 300px) Medientyp screen and (max-width: 300px) Verknüpfung screen and (max-width: 300px) Ausdruck screen and ( max-width: 300px ) Merkmal screen and ( max-width : 300px) Wert screen and (max-width: 300px )
  • 29. Das Schlüsselwort and drückt ein logisches Und aus. screen and (max-width: 300px) (min-width: 450px) and (max-width: 950px)
  • 30. Ein Komma steht für ein logisches Oder. @import url(&quot;style.css&quot;) screen , projection; <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot;screen and (min-width: 800px) , projection and (min-width: 800px)&quot; />
  • 31. Das Schlüsselwort not steht für eine logische Negation. <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot; not screen and (color)&quot; />
  • 32. Das Schlüsselwort only ist ein Workaround für veraltete Browser, die mit Media Queries nicht umzugehen wissen <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; media=&quot; only screen and (color)&quot; />
  • 33. CSS Media Queries Medienmerkmale
  • 34. Breite und Höhe Merkmal min/max Beschreibung width Ja Breite der Anzeigefläche height Ja Höhe der Anzeigefläche device-width Ja Breite des Geräts device-height Ja Höhe des Geräts
  • 35. Viewport mindestens 500px hoch? <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;vertical-align.css&quot; media=&quot;screen and ( min-height: 500px )&quot; />
  • 36. Smartphone? @media only screen and ( min-device-width: 320px ) and ( max-device-width: 480px ) { … }
  • 37. Gerät- und Viewportbreite Achtung! Breite des Viewports ist häufig größer als die des Geräts selbst <meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;> Weitere Informationen: http://www.quirksmode.org/blog/archives/2010/09/combining_meta.html
  • 38. Seitenverhältnis und Ausrichtung Merkmal min/max Beschreibung aspect-ratio Ja Verhältnis der Merkmale width und height device-aspect-ratio Ja Verhältnis der Merkmale device-width und device-height orientation Nein Ausrichtung des Geräts
  • 39. Seitenverhältnis 16:9? @media only screen and ( device-aspect-ratio: 16/9 ) { … } @media screen and ( device-aspect-ratio: 1280/720 ) { … }
  • 40. Horizontale oder vertikale Ausrichtung eines iPad? <link … href=&quot;ipad-portrait.css&quot; media=&quot;(min-device-width: 768px) and (max-device-width: 1024px) and ( orientation: portrait )&quot; /> <link … href=&quot;ipad-landscape.css&quot; media=&quot;(min-device-width: 768px) and (max-device-width: 1024px) and ( orientation: landscape )&quot; />
  • 41. Farbmerkmale Merkmal min/max Beschreibung color Ja Farbtiefe des Geräts color-index Ja Anzahl der Einträge in der Farb-Lookup-Tabelle des Geräts monochrome Ja Anzahl der Bits pro Pixel im Bildspeicher eines einfarbigen Geräts
  • 42. Schwarzweiß- oder Farbdrucker? <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;print-color.css&quot; media=&quot;print and ( color )&quot; /> <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;print-monochrome.css&quot; media=&quot;print and ( monochrome )&quot; />
  • 43.  
  • 44. iPhone4? <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/retina.css&quot; media=&quot;only screen and ( -webkit-min-device-pixel-ratio: 2 )&quot; />
  • 46.  
  • 48. Michael Jendryschik [email_address] [email_address] twitter.com/jendryschik www.facebook.com/jendryschik www.xing.com/profile/Michael_Jendryschik
  • 50. Abbildungsnachweis http://www.digitale-chancen.de/transfer/assets/468.jpg http://ceipntrasradelapiedad.files.wordpress.com/2010/03/braille.jpg http://gadgets.boingboing.net/Palm-Pre-Disassembled.jpg http://upload.wikimedia.org/wikipedia/commons/d/dc/Westermann_Druckerei_1890.png http://www.infocus.rbt-pressroom.eu/de/download/der-heimkino-projektor-sp8602-kommt-vielen-hochleistungsfhigen-eigenschaften-auf-den-markt-4.jpg http://upload.wikimedia.org/wikipedia/commons/2/2c/Monitor_in_gutter.jpg http://cmsdata.iucn.org/img/original/iberian_lynx_by_antonio_rivas.jpg http://www.comcast.com/MediaLibrary/1/1/About/PressRoom/Images/LogoAndMediaLibrary/Photography/CableNetworks/Teletubbies-Group2.jpg http://www.audiobooks.at/images/cover/europa/DDF_132_CD.jpg http://www.pm.ruhr-uni-bochum.de/imperia/md/images/pressestelle/einstein.jpg http://img2.fengniao.com/product/28/473/ceOnyLQihT8xg.jpg http://www.apple.com/iphone/ http://wallpapers-diq.net/wallpapers/30/Firefox%2C_The_Browser%2C_Reloaded.jpg