• Home
  • Google Plus
  • Facebook
  • Twitter
  • Xing
  • RSS-Feed

Andi Licious' Blogosphäre

Neues aus der Welt rund um und mit Andi Licious.

Responsive Webdesign – CSS3 Media Queries – CSS-Vorlage für Browser und mobile Geräte

28. Juni 2012 um 19:26 Uhr | Internet | Andi Licious
Responsive Webdesign - CSS3 Media Queries - CSS-Vorlage für Browser und mobile Geräte

Gestern hatte ich es mit dem Bookmarklet für die CSS3 Media Queries, heute gibt’s dann eine CSS-Vorlagen-Datei für die Allgemeinheit. Der Hintergrund ist ziemlich einfach erklärt: Wenn du nicht gerade jeden Tag mit Responsive Webdesign zu tun hast, wirst du dir in der Regel entweder eine ziemlich alte Liste von irgendeiner Website kopieren oder dich hinsetzen und das zusammentragen & -fragen, was du benötigst oder was dir vor allem unter die Augen gekommen ist.

Ich habe mich jetzt einmal hingesetzt und alle wichtigen Angaben zusammengetippt, um eine grundlegende Vorlage zu haben, aus der man nicht gewünschte Daten rausstreichen kann, anstatt sich permanent weitere einzufügen. Dies ist natürlich auch weiterhin möglich, doch ich bezweifele, dass ihr wirklich alle Stages aus der Vorlage nutzen werdet. ;)

Damit’s aber auch schon anschaulich wird, habe ich eine sehr einfache Demo-Website erstellt, auf der ihr die jeweiligen Auswirkungen euch einmal ansehen könnt. Natürlich auch, wenn euch die CSS3 Media Queries bisher eher kein Begriff waren.

So könnt ihr zum Bespiel testen: Öffnet die Demo in eurem Browser und skaliert einfach einmal frei an der Fenstergröße herum. Ihr werdet sehen, dass sich der Inhalt je nach Fenstergröße automatisch anpasst. Dies geht natürlich dann besonders gut, wenn ihr es nicht gerade auf einem Netbook oder einem anderen winzigen Display testet. Aber mobil geht’s natürlich auch, doch ich möchte euch nicht zumuten die lange URL im mobilen Browser einzutippen, dafür gibt’s hier auch den passenden Shortlink:

Demo: http://www.andilicious.com/myfiles/dev/css/responsive-webdesign-css3-media-queries/
Shortlink: http://mnfw.de/i3

Ihr habt Fragen zu diesem Thema? Schreibt einfach hier in die Kommentare, auf Facebook, Twitter usw. … ihr wisst schon. Die Vorlage darf natürlich beliebig verwendet, geändert und weitergeben werden. Über einen Link zu diesem Artikel würde ich mich aber dennoch sehr freuen. ;)

Wem die untenstehende Datei hier im Artikel ein wenig zu unübersichtlich ist, hier gibt’s sie auch zum Download: http://www.andilicious.com/myfiles/dev/css/responsive-webdesign-css3-media-queries/css_responsive_template.css

 

/* --------------------------------------------------------- */
/* BASIC CSS ----------------------------------------------- */
/* --------------------------------------------------------- */

	/* YOUR STYLES */






/* --------------------------------------------------------- */
/* MEDIA QUERIES ------------------------------------------- */
/* --------------------------------------------------------- */


/* --------------------------------------------------------- */
/* INFORMATION --- Version 1.1 --- 2012-VII-05 ------------- */
/* --------------------------------------------------------- */

/* ###

1.) Use e.g. "Respond.js" by Scott Jehl to enable responsive web designs in browsers that don't support CSS3 Media Queries (e.g. Internet Explorer 6, 7, 8) --> https://github.com/scottjehl/Respond/

2.) In this case, I use stages for all sizes. Between 1001 pixel and 1249 pixel the browser uses your basic-CSS. You can always delete some stages. After check the stages and adjust some min/max widths. (e.g. If you want to use only one stage for smartphones up to 320 width and one stage for smartphones and devices up to 960 pixel, delete the stages between and set the two new stages for a larger range.)

3.) If you think "Oh, the iPhone 4 has a 640x960 pixel display, so my stage needs only to fit on this in portrait and landscape orientation", it's a trap. The iPhone 4 has this resolution, but it uses only 320x480 pixel device-width. Or the Samsung Galaxy S2. It has a 480x800 pixel display --> 320x450 pixel and 320x508 pixel device-width in portrait orientation / 533x237 pixel in width and device-width in landscape orientation. // Quick Tip: "Tablet Computer - 150+ Display Measurements" --> http://www.designfalcon.com/#tablets

4.) Think about PNG-Fix for old IE (e.g. "jquery.pngFix.js" by Andreas Eberhard --> http://jquery.andreaseberhard.de/pngFix/), IE Background-Fix (e.g. "backgroundSize.js" by Louis Remi --> https://github.com/louisremi/jquery.backgroundSize.js) and last but noch least a emulator for CSS3 pseudo classes and attribut selectors for old IE (e.g. "Selectivizr.js" by Keith Clark --> http://selectivizr.com/).

5.) More information about "max-width" and "max-device-width": "max-width" refers to the actual viewport and can target specific sizes and orientations; "max-device-width" refers to the device viewport size, regardless of browser-scale, orientation or resizing. Shorthand: "max-width" (and "max-height") = target display area // "max-device-width" (and "max-device-height") = device entire rendering area. Same for "min" values.

6.) Thanks for your time! (: Andi "Licious" Wieser (Oh, you have some time left or further questions? --> andilicious.com // twitter.com/andiliciouscom // fb.com/andiliciouscom // pinterest.com/licious).

### */




/* --------------------------------------------------------- */
/* APPLE MACBOOK PRO RETINA ETC. --------------------------- */
/* --------------------------------------------------------- */

/* Retina Displays/Screens (2880x1800) --------------------- */
@media
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2/1),
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 2dppx) {
}




/* --------------------------------------------------------- */
/* SMARTPHONES, TABLETS & TINY DESKTOPS -------------------- */
/* --------------------------------------------------------- */

/* Old Smartphones (portrait and landscape) ---------------- */
@media
only screen and (min-device-width: 240px) and (max-device-width: 320px) {
	/* YOUR STYLES */
}


/* Old Smartphones (e.g. portrait) ------------------------- */
@media
only screen and (max-width: 319px) {
	/* YOUR STYLES */
}


/* Smartphones (portrait and landscape) -------------------- */
@media
only screen and (min-device-width: 320px) and (max-device-width: 640px) {
	/* YOUR STYLES */
}


/* Smartphones (portrait) & Old SP (landscape) ------------- */
@media
only screen and (min-width: 320px) and (max-width: 479px) {
	/* YOUR STYLES */
}


/* Smartphones (landscape) & Old Tablets (Portrait) -------- */
@media
only screen and (min-width: 480px) and (max-width: 639px) {
	/* YOUR STYLES */
}


/* Smartphones & Tablets (portrait & landscape) ------------ */
@media
only screen and (min-device-width: 640px) and (max-device-width: 960px) {
	/* YOUR STYLES */
}


/* Smartphones & Tablets (portrait) & Tiny Desktops -------- */
@media
only screen and (min-width: 640px) and (max-width: 799px) {
	/* YOUR STYLES */
}


/* Smartphones & Tablets (landscape) & Splitted Desktops --- */
@media
only screen and (min-width: 800px) and (max-width: 1000px) {
	/* YOUR STYLES */
}





/* --------------------------------------------------------- */
/* DEVICES BY RATIO ---------------------------------------- */
/* --------------------------------------------------------- */

/* LowRes (e.g. 240x320 / 320x480) ------------------------- */
@media
only screen and (min--moz-device-pixel-ratio: 0.75),
only screen and (-o-min-device-pixel-ratio: 3/4),
only screen and (-webkit-min-device-pixel-ratio: 0.75),
only screen and (min-device-pixel-ratio: 0.75),
only screen and (min-resolution: 0.75dppx) {
	/* YOUR STYLES */
}


/* HighRes ------------------------------------------------- */
@media
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5),
only screen and (min-resolution: 1.5dppx) {
	/* YOUR STYLES */
	
	/* e.g. HighRes Logo (use _2x as extension for double-sized images) */
	/* .logo {background-image: url(logo_2x.png); background-size: 50%;} */
}


/* RetinaRes Smartphones (e.g. iPhone 4 / portrait) -------- */
@media
only screen and (min--moz-device-pixel-ratio: 1.5) and (orientation: portrait),
only screen and (-o-min-device-pixel-ratio: 3/2) and (orientation: portrait),
only screen and (-webkit-min-device-pixel-ratio: 1.5) and (orientation: portrait),
only screen and (min-device-pixel-ratio: 1.5) and (orientation: portrait),
only screen and (min-resolution: 1.5dppx) and (orientation: portrait) {
	/* YOUR STYLES */
}


/* RetinaRes Smartphones (e.g. iPhone 4 / landscape) ------- */
@media
only screen and (min--moz-device-pixel-ratio: 1.5) and (orientation: landscape),
only screen and (-o-min-device-pixel-ratio: 3/2) and (orientation: landscape),
only screen and (-webkit-min-device-pixel-ratio: 1.5) and (orientation: landscape),
only screen and (min-device-pixel-ratio: 1.5) and (orientation: landscape),
only screen and (min-resolution: 1.5dppx) and (orientation: landscape) {
	/* YOUR STYLES */
}





/* --------------------------------------------------------- */
/* IPADS --------------------------------------------------- */
/* --------------------------------------------------------- */

/* iPads (portrait and landscape) -------------------------- */
@media
only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
	/* YOUR STYLES */
}


/* iPads (portrait) ---------------------------------------- */
@media
only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
	/* YOUR STYLES */
}


/* iPads (landscape) --------------------------------------- */
@media
only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
	/* YOUR STYLES */
}


/* iPad Retina (iPad 3; portrait and landscape) ------------ */
@media
only screen and (min-device-width: 1536px) and (max-device-width: 2048px) and (min--moz-device-pixel-ratio: 2),
only screen and (min-device-width: 1536px) and (max-device-width: 2048px) and (-o-min-device-pixel-ratio: 2/1),
only screen and (min-device-width: 1536px) and (max-device-width: 2048px) and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-width: 1536px) and (max-device-width: 2048px) and (min-device-pixel-ratio: 2),
only screen and (min-device-width: 1536px) and (max-device-width: 2048px) and (min-resolution: 2dppx) {
	/* YOUR STYLES */
}





/* --------------------------------------------------------- */
/* COMPUTERS / OTHER DEVICES ------------------------------- */
/* --------------------------------------------------------- */

/* Displays/Screens (e.g. MacBook @ 1280x800) -------------- */
@media
only screen and (min-width: 1250px) and (max-width: 1409px) {
	/* YOUR STYLES */
}


/* Displays/Screens (e.g. 19" WS @ 1440x900) --------------- */
@media
only screen and (min-width: 1410px) and (max-width: 1649px) {
	/* YOUR STYLES */
}


/* Displays/Screens (e.g. 22" WS @ 1680x1050) -------------- */
@media
only screen and (min-width: 1650px) and (max-width: 1889px) {
	/* YOUR STYLES */
}


/* Displays/Screens (e.g. 24" WS @ 1920x1080) -------------- */
@media
only screen and (min-width: 1890px) and (max-width: 2529px) {
	/* YOUR STYLES */
}


/* Really Large Displays/Screens (e.g. 2560x1440) ---------- */
@media
only screen and (min-width: 2530px) {
	/* YOUR STYLES */
}
Tags: , , , , , , , , , ,
t3n Magazin - Jetzt im Abo bestellen

7 Kommentare zu “Responsive Webdesign – CSS3 Media Queries – CSS-Vorlage für Browser und mobile Geräte

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Kalender
Mai 2013
M D M D F S S
« Apr    
 12345
6789101112
13141516171819
20212223242526
2728293031  
Monatsarchiv
Bloggertreffen 2012 in Köln
wpSEO
t3n
mainflow agency
DesignFalcon.com

© Andi Licious' Blogosphäre

|

Interpretiert von DesignFalcon und mnfw. Powered by WordPress.