概要と目標 ベース部分のCSSと
ヘッダー部分を完成さる
ブラウザが持っているスタイルを消して、サイト全体で共通するスタイルと、
ヘッダーやメイン部分のスタイルを定義しよう。
ブラウザが持っているスタイルを消して、サイト全体で共通するスタイルと、
ヘッダーやメイン部分のスタイルを定義しよう。
ブラウザが持っているデフォルトのmarginや、paddng、 font-sizeなどのスタイルを消そう。
ブラウザのスタイルを消すには、「*(全称セレクタ)」を使う場合や、
「reset.css」というリセット用のCSSを使うなどいくつかの方法がある。
title要素の下で「common.css」をリンクする<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dummy Cafe | 「いつもの。」が通じるあなたのカフェ</title>
<link rel="stylesheet" href="css/common.css">
</head>
@charset "UTF-8";
/* ===============================================
Base
=============================================== */
/*
Reset
----------------------------------------------- */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
main, menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, main, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
文字サイズや、文字の色、書体、背景色など、サイトのベースとなるCSSを
詳細度の低い要素セレクタで指定する。
また、今回はGoogle Fontsの「Noto Sans JP」というWebフォントを使う練習も行いましょう。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dummy Cafe | 「いつもの。」が通じるあなたのカフェ</title>
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:400,700">
</head>
| セレクタ | プロパティ | 値 |
|---|---|---|
body |
書体 | 'Noto Sans JP', '游ゴシック', 'Yu Gothic', '游ゴシック体', 'YuGothic', |
| 行間 | 1.5 |
|
| 文字の色 | #212121 |
|
img |
縦方向の位置揃え | 下 |
/*
Default Style
----------------------------------------------- */
body {
font-family: 'Noto Sans JP', '游ゴシック', 'Yu Gothic', '游ゴシック体', 'YuGothic', 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', 'Meiryo UI', 'メイリオ', Meiryo, sans-serif;
line-height: 1.5;
color: #212121;
}
img {
vertical-align: bottom;
}
「.container」でマークアップした範囲をセンタリングしよう。
.container」にボックスをセンタリングするCSSを記述
/* ===============================================
Layout
=============================================== */
/*
Centering
----------------------------------------------- */
.container {
width: 960px;
margin: 0 auto;
}
ロゴの位置や、各リスト項目を横並びで配置し、ヘッダーを完成させる。
/*
Header
----------------------------------------------- */
#header {
background-color: #212121;
color: #fff;
}
#header h1 {
text-align: center;
padding: 1.75em 0;
}
#header-nav {
overflow: hidden;
}
#header-nav li {
width: 20%;
float: left;
text-align: center;
}
#header-nav a {
display: block;
text-decoration: none;
color: #fff;
padding: .75em 0;
}
#header-nav a:hover {
background-color: #333;
}
各セクションの余白や背景の色のCSSを調整する
/*
Main
----------------------------------------------- */
#main {
clear: both;
}
.section {
padding: 3em 0;
}
.section-grey {
background-color: #f0f0f0;
}