Responsive TYPO3
Responsive Web Design
Sven Wolfermann | maddesigns
TYPO3 Akademie 2012 · München, 10.02.2012
Twittern: @maddesigns #t3ak12 #rt3
Responsive Web Design
Sven Wolfermann | maddesigns
TYPO3 Akademie 2012 · München, 10.02.2012
Twittern: @maddesigns #t3ak12 #rt3
Webseiten waren grundsätzlich schon immer flexibel und haben sich an die Bildschirmauflösung angepasst.
2011 wurden erstmals mehr Smartphones als Desktop-PCs verkauft
(natürlich auch unvollständig)
Ein Viertel der Deutschen surft via Smartphone im Internet
Herzlich Willkommen!
Verschiedene Screens, aber die Website passt sich an!
Responsive Design bezeichnet eine Praxis im Webdesign, bei der der grafische Aufbau von Webseiten dynamisch und unter Berücksichtigung der Anforderungen des betrachtenden Gerätes erfolgt … eine Webseite wird somit auf einem großen Display anders dargestellt als auf einem Tablet-PC oder Smartphone.
Wo nutzen Menschen ihre mobilen Geräte?
/* Smartphones (portrait and landscape) */ @media only screen and (min-device-width : 320px) and (max-device-width : 480px) { /* CSS Styles */ } /* Tablets (portrait and landscape) */ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) { /* CSS Styles */ } /* Desktops and Laptops */ @media only screen and (min-width : 1024px) { /* CSS Styles */ }
geht auch bei extern eingebundenen Dateien
<link rel="stylesheet" href="smartphone.css" media="only screen and (min-device-width : 320px) and (max-device-width : 480px)">
für höhere Auflösung optimiertes CSS - iPhone4
<link rel="stylesheet" href="iphone4.css" media="only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5)">
@media screen and (max-width: 600px) { header, footer, .main { float: none; width: auto; } }
keine statische Medieninhalte
img, embed, object, video { max-width: 100%; }
Chrome seit Version 4.0 (aktuell Version 17)
Firefox seit Version 3.5 (aktuell Version 10)
Opera / Mobile seit Version 9.5 / 10.0 (11.6 / 11.5)
Safari / iOS seit Version 4.0 / 3.2 (5.1 / 5.0)
Android seit Version 2.1 (4.0)
IE / mobile seit Version 9.0 / 9.0 (Version 9.0)
img, embed, object, video { max-width: 100%; height: auto; width: auto; } /* CSS Styled Content Regeln überschreiben */ DIV.csc-textpic-above DIV.csc-textpic-imagewrap, DIV.csc-textpic-below DIV.csc-textpic-imagewrap, DIV.csc-textpic DIV.csc-textpic-imagewrap UL LI, DIV.csc-textpic DIV.csc-textpic-imagewrap DL.csc-textpic-image { float: none; }
TypoScript
feste CSS style=""
Anweisungen in CSS-Style-Content müssen überschrieben werden
tt_content.image.20 { imageStdWrap.dataWrap = <div class="csc-textpic-imagewrap"> | </div> imageColumnStdWrap.dataWrap = <div class="csc-textpic-imagecolumn"> | </div> }
Auch beim Rendering selbst muss das style-Attribut entfernt werden.
tt_content.image.20 { rendering { dl { imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow"> | </div> imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last"> | </div> oneImageStdWrap.dataWrap = <dl class="csc-textpic-image###CLASSES###" > | </dl> } ul { imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow"><ul> | </ul></div> imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last"><ul> | </ul></div> oneImageStdWrap.dataWrap = <li class="csc-textpic-image###CLASSES###"> | </li> } div { imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow"> | </div> imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last"> | </div> oneImageStdWrap.dataWrap = <div class="csc-textpic-image###CLASSES###"> | </div> } simple { imageStdWrap.dataWrap = <div class="csc-textpic-imagewrap csc-textpic-single-image"> | </div> } } }
Gleich mal das Rendering auf HTML5 umstellen
tt_content.image.20 { renderMethod = figure rendering { figure { imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow"> | </div> imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last"> | </div> noRowsStdWrap.wrap = oneImageStdWrap.dataWrap = <figure class="csc-textpic-image"> | </figure> imgTagStdWrap.wrap = | editIconsStdWrap.wrap = <div> | </div> caption.wrap = <figcaption> | </figcaption> caption.required = 1 } } }
Adaptive Bilder
Problem ist, dass sich Bilddatenmengen nicht dynamisch anpassen
Große Bilder werden zwar verkleinert dargestellt, laden aber unnötige Datenmengen
<img> Tag ist nicht dafür ausgelegt
Polyfills müssen her
http://nicolasgallagher.com/responsive-images-using-css3/
<img src="image.jpg" alt="" data-src-600px="image-600px.jpg">
https://github.com/filamentgroup/Responsive-Images
<img src="small.jpg?full=large.jpg">
Die aktuell beste Lösung meiner Meinung nach ist die <noscript>-Lösung mit HTML5 data
-Attributen
<noscript data-large="Koala.jpg" data-small="Koala-small.jpg" data-alt="Koala"> <img src="Koala.jpg" alt="Koala" /> </noscript>
tt_content.image.20 { maxW = 960 maxW.override.data > maxWInText = {$styles.content.imgtext.maxWInText} maxWInText.override.data = register:maxImageWidthInText imageStdWrap.dataWrap.cObject = COA imageStdWrap.dataWrap.cObject { 1 = TEXT 1.value = <div class="csc-textpic-imagewrap"><noscript 10 = IMG_RESOURCE 10 { file.import.data = TSFE:lastImageInfo|origFile file.maxW = 480 file.override.data = {$styles.content.imgtext.maxW} stdWrap.noTrimWrap = | data-small="|" | } 20 = IMG_RESOURCE 20 { file.import.data = TSFE:lastImageInfo|origFile file.maxW = {$styles.content.imgtext.maxW} file.override.data = register:maxImageWidth stdWrap.noTrimWrap = | data-large="|" | } 1000 = TEXT 1000.value = >|</noscript></div> } }
jQuery #FTW
$('noscript[data-large][data-small]').each(function(){ var src = screen.width >= 500 ? $(this).data('large') : $(this).data('small'); $('<img src="' + src + '" alt="' + $(this) .data('alt') + '" />') .insertAfter($(this)); });
Extension installieren, statisches TypoScript einbinden
TypoScript
10 = IMAGE 10.file = fileadmin/images/myimage.jpg 10.file.width = 800 10.breakpoint = 1200 10.breakpoints = 600:500, 400:280, 320:160
Fluid ViewHelper
{namespace responsive=Tx_RtpImgquery_ViewHelpers} <responsive:image src="fileadmin/images/myimage.jpg" alt="alt text" breakpoint="900" breakpoints="600:500, 400:280, 320:160" />
für Bilder können in jedem Inhaltselement Breakpoints gesetzt werden
“Ich hab genau zugehört, aber was ist nochmal … ?”
Sven Wolfermann | maddesigns