More Related Content Similar to 「html5 boilerplate」から考える、これからのマークアップ (20) More from Yasuhito Yabe (17) 「html5 boilerplate」から考える、これからのマークアップ2. 1)構成フ イ
ァ ルを確認してみよう
2)各フ イ
ァ ルを検証してみよう
3)も と便利にBoilerplateを使う
っ には
6. W eb
W eb/DTP
W eb
W eb S
1/20
13. テンプレート ァ ル
フ イ
cssフ ルダ / imgフ ルダ / jsフ ルダ /
ォ ォ ォ
apple-touch-icon群 / favicon.ico /
index.html / 404.html /
crossdmain.xml / humans.txt / robot.txt /
.htaccess
docsフ ルダ / LICENSE.md /
ォ
README.md / CHANGELOG.md
ドキ メン フ イ
ュ ト ァ ル
14. cssフ ルダ / imgフ ルダ / jsフ ルダ /
ォ ォ ォ
apple-touch-icon群 / favicon.ico /
index.html / 404.html /
crossdmain.xml / humans.txt / robot.txt /
.htaccess
docsフ ルダ / LICENSE.md /
ォ
README.md / CHANGELOG.md
18. <!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser.
Please <a href="http://browsehappy.com/">upgrade your browser</a> or
<a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
<p>Hello world! This is HTML5 Boilerplate.</p>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"></script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src='//www.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</body>
</html>
19. <!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
21. <script src="//ajax.googleapis.com/ajax/libs/
jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write(
'<script src="js/vendor/jquery-1.9.1.min.js"></script>'
)</script>
<script src="js/plugins.js"></script> CDNの読み込みと
<script src="js/main.js"></script> フ ォールバック
<!-- Google Analytics:
change UA-XXXXX-X to be your site's ID. -->
(GAト ラッキングタ グ→省略)
</body>
JavaScriptはBody要素の閉じタグの直前
23. CDNの読み込みとフォールバック
CDNの読み込みは、 プロトコル http / https)
( を省略
→ htmlファ ルに合ったプロトコルを自動的に選択
イ
ただし、 配布元のSSL対応には注意
CDNに接続できない場合のフォールバック
→ 接続できない場合のみ、ローカルのファ ルを参照
イ
(表示速度向上のため、有名ライブラリのキャッシュ イ
ファ ルを効率的に使う)
26. Normalize.css ?
表示をゼロにしない
(sup や sub を使えば上付き、下付きになるし、 は箇条書きになる)
ul
バグ補正
( pre 要素における font-size、 9 における SVG の overflow の挙動など)
IE
CSS 解析時に、必要以上のゴミとなるコードを作らない
(リセット系 CSS は結果的にゴミとなる margin:0 などが大量に挿入される)
必要に応じて不要箇所を削除しても OK
( Nomalize.css は適切にコメントで区切られていて、不要箇所は削除が簡単)
http://www.yomotsu.net/blog/2013/02/23/normalize.html
30. .ir { background-color: transparent;
border: 0;
overflow: hidden;
*text-indent: -9999px; /* IE 6/7 fallback */
}
.ir:before { content: "";
display: block;
width: 0;
height: 150%;
}
31. <h1 class="logo ir">
静岡のWeb系勉強会/セミナー Knock! Knock!
</h1>
.logo {
width: 220px;
height: 160px;
background: url(/img/logo.png) no-repeat;
}
33. /*
* Hide from both screenreaders and browsers
*/ ヴ ジュ
ィ アル上もス リー ク ンリーダーでも消え る
.hidden {
display: none !important;
visibility: hidden;
}
34. /* Hide only visually,
but have it available for screenreaders */
ス リー
ク ンリーダーでは読み上げ
.visuallyhidden { ヴ ジュ
ィ アル上では消える
border: 0; clip: rect(0 0 0 0);
height: 1px; margin: -1px;
overflow: hidden; padding: 0;
position: absolute; width: 1px;
}
35. /* Hide visually and from screenreaders,
but maintain layout */
ィ アル/ス リー
ヴ ジュ ク ンリーダーからは消え る
.invisible { レイ ト
アウ 上は残る
visibility: hidden;
}
39. min-widthの単位はem
@media only screen and (min-width: 35em) {
/* Style adjustments for viewports that meet the condition */
}
These examples override the primary ('mobile first') styles.
@media print, (モバイ ルファーストな基本ス ルを上書きする)
タイ
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
/* Style adjustments for high resolution devices */
}
42. Modernizer.js ?
Modernizr is a JavaScript library that
detects HTML5 and CSS3 features in
the user’ browser.
s
http://modernizr.com/
Modernizrは HTML 5とユーザーのブラウザ
にCSS 3の機能を検出するJavaScriptライブ
ラリです。 (Google 翻訳)
43. <html class="no-js" lang="ja">
<html class=" js flexbox canvas canvastext webgl
no-touch geolocation postmessage websqldata-
base indexeddb hashchange history dragand-
drop websockets rgba hsla multiplebgs back-
groundsize borderimage borderradius boxshad-
ow textshadow opacity cssanimations csscol-
umns cssgradients cssreflections csstransforms
csstransforms3d csstransitions fontface generat-
edcontent video audio localstorage sessionstor-
age webworkers applicationcache svg inlinesvg
smil svgclippaths" lang="ja">
45. // Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
consoleに対応していないブラウザでも
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
]; エラー表示を出さないようにする
var length = methods.length;
var console = (window.console = window.console || {});
while (length--) {
method = methods[length];
if (!console[method]) {
console[method] = noop;
}
}
}());
60. 本日はあ がと ございま
り う した
ご連絡・ご質問など下記までお願いし ます
E-mail : info@hamnaly.com
Facebook / Twitter : yabecchy