Upload
ontico
View
2.255
Download
8
Embed Size (px)
DESCRIPTION
Citation preview
Адаптивный веб-дизайнна практике
Антон Епрев[email protected]
goo.gl/YFsuS
2
Responsive Web Designo Резиновая версткаo Плавающие изображенияo Медиа-запросы
3
goo.gl/rCZ4Z
4
Mobile FirstИспользование мобильного интернета удваивается с каждым годом [goo.gl/F17AD]
В рунете 10% посещений приходятся на мобильные устройства [goo.gl/fBLCF]
5
Mobile Firsto Фокус на главномo Полнофункциональная мобильная версияo Рабочая большая версия
6
Мобильные браузеры
goo.gl/vfs1d7
Классы поддержки браузеровGraded Browser Support [goo.gl/3vbtC]
C: IE7-A: IE8/9, Chrome, Safari, Firefox, Opera,
Opera Mobile, Opera Mini 4/6X: Chrome 12, Firefox 4, Opera 10
8
Отрубаем концы<!DOCTYPE html><html><head> <!--[if !(IE)|(gte IE 8)]><!--> <link type="text/css" ... /> <script ...></script> <!--<![endif]--></head><body> ...</body></html>
10
Progressive Enhancement+ Гарантированная работа сервиса в
любом устройстве+ Возможность выкатывать новые
изменения раньше– Сложность реализации
11
12
Требования к веб-дизайнуo«Pixel-perfect»oПоддержка touch-устройствoМинимальное поддерживаемое
разрешение 240px
13
14
15
16
Настрой Viewport<meta name="viewport" content=" width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0" />
17
Поддержка:hovervar touch = 'ontouchstart' in window;$('html').addClass( touch ? 'touch-yes' : 'touch-no');
.touch-no .item .item__link { display: none;}.touch-no .item:hover .item__link { display: block;}
18
Определение возможностейvar video = !!document.createElement('video').canPlayType;
var flash = (typeof navigator.plugins['Shockwave Flash'] == 'object');
if (!flash && typeof window.ActiveXObject != 'undefined') try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); flash = true; } catch (e) {}
19
Отлавливаем scroll<ul class="feed"> <li class="feed__item">...</li> <!-- ... --> <li class="feed__next-page">...</li></ul>
.feed__next-page { display: block; }
$(document).one('scroll', function() { $('.feed__next-page').hide();});
20
Desktop vs. Mobile
21
Облегчаем функционалvar desktop = screen.width > 768 && !touch;
$('.button').click(function (e) { if (desktop) { e.preventDefault(); // AJAX }});
22
Задача
24
Каркас<a href="#" class="button"> <span class="button__inner"></span></a>
.button { // Sass (SCSS) padding: $border-width; height: $height - $border-width * 2;}.button__inner { line-height: $height - $border-width * 2;}
25
<a href="#" class="button"> <span class="button__inner"> <img src="empty.png" class="button__icon" alt="Icon" /> </span></a>
.button__icon { width: ...; height: ...; background:...;}
IE6: Chrome:
26
<a href="#" class="button"> <span class="button__inner"> <img src="empty.png" class="button__icon" alt="Icon" /> </span></a>
.button__icon { width: ...; height: ...; background:...;}
IE6: Chrome:
27
<a href="#" class="button"> <span class="button__inner"> <i class="button__icon">Icon</i> </span></a>
.button__icon { ... text-indent: -9999px;}
IE6: Chrome:
28
<a href="#" class="button"> <span class="button__inner"> <i class="button__icon">Icon</i> <u class="button__text">Text</u> </span></a>
<button class="button"> <span class="button__inner"> <i class="button__icon">Icon</i> <u class="button__text">Text</u> </span></button>
29
.button { height: $height - $border-width * 2;}
.button { @include box-sizing(content-box); height: $height - $border-width * 2;}
<A> <BUTTON>
30
.button { height: $height - $border-width * 2;}
.button { @include box-sizing(content-box); height: $height - $border-width * 2;}
<A> <BUTTON>
31
Opera Mini и line-height.button__inner { line-height: $height - $border-width * 2;}
<A> <BUTTON>
32
Opera Mini и line-height.button__inner { line-height: 1; // сбрасываем для всех padding: ( $height - $border-width * 2 - $font-size )/2 0; height: $font-size;}
<A> <BUTTON>
33
Handheld!Режимы Opera Mini:o Desktopo Mobile
См. goo.gl/XixDM
34
Handheld!Режимы Opera Mini:o Desktopo Mobile
См. goo.gl/XixDM
35
Handheld!Режимы Opera Mini:o Desktopo Mobile
См. goo.gl/XixDM
36
<link href="..." rel="stylesheet" type="text/css" media="all"/>
<link href="..." rel="stylesheet" type="text/css" media="all, handheld"/>
37
<link href="..." rel="stylesheet" type="text/css" media="all"/>
<link href="..." rel="stylesheet" type="text/css" media="all, handheld"/>
38
@media screen and (max-width: 320px) { .button__text { display: none; }}
39
Handheld!@media screen and (max-width: 320px) { .button__text { display: none; }}
@media handheld, screen and (max-width: 320px) { .button__text { display: none; }}
40
Handheld!@media screen and (max-width: 320px) { .button__text { display: none; }}
@media handheld, screen and (max-width: 320px) { .button__text { display: none; }}
41
Handheld!@media screen and (max-width: 320px) { .button__text { display: none; }}
@media all and (max-width: 320px) { .button__text { display: none; }}
42
Особенности click в iOS<a class="button">...</a>
.button { ...}
$('body').delegate( '.button', 'click', function () { // :) });
43
Особенности click в iOS<div class="button">...</div>
.button { ...}
$('body').delegate( '.button', 'click', function () { // :( });
44
Особенности click в iOS<div class="button">...</div>
.button { cursor: pointer;}
$('body').delegate( '.button', 'click', function () { // :) });
45
Особенности click в iOS<div class="button">...</div>
.button { cursor: pointer;}
$('body').delegate( '.button', 'click', function () { // :) });
46
Ни жив, не мёртв…o {position: fixed}
iOS 5, Android 3, Opera Mobile
o {overflow: scroll}iOS 5, Android 3.2
o Opera Mini: JavaScriptСм. goo.gl/XixDM
47
Средства разработчикаo iOS Simulatoro Opera Mobile Emulator [goo.gl/QIkmf]o Opera Mini Online Simulator [goo.gl/fHEv4]o Opera Remote Debuggingo Weinre [goo.gl/TmXxo]o Adobe Shadow [goo.gl/hfN6Y]
48
49
50
51
52
53
Q&A
Антон Епрев[email protected]