よく思うんですが、CSSでもHTMLでも、他の人が書いたものを修正したりするのってすごく面倒。
特にCSSは、どこに何が書いてあって、どれとどれが影響し合って..と、分析しないといけないし、意味なさそうに見えた一言がブラウザ対応のおまじないだったり、自分で書く方がずっと早いんじゃないかと思ってしまったりします。
そこで!と言ってはなんですが、Twenty TenのCSSにコメント入れてみました。今までこのブログに書いたあたりまでですが。
関連すると思われる記事にリンクもしました。少しは該当する場所が探しやすくなるかな。では上から順にいきます!
目次
今回は一番始めのリセットからコンテンツまでです。
1. リセット
一番上はブラウザの表示をそろえるためにいったんすべてをリセットするCSSです 。ちょこちょこっとコメント入れました。
/* =Reset default browser CSS. Based on work by Eric Meyer: http://meyerweb.com/eric/tools/css/reset/index.html
-------------------------------------------------------------- */
/* ブラウザの表示をそろえるためにいったんすべてをリセットするCSSです
ここは特にいじらなくてもよさそうです
お好みの Reset CSS に変えてもいいですね。*/
/* マージンや余白を 0にそろえる */
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, font, 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 {
background: transparent;
border: 0;
margin: 0;
padding: 0;
vertical-align: baseline;
}
body {
line-height: 1;
}
/* h1〜 h6 フォントの太さをノーマルに*/
h1, h2, h3, h4, h5, h6 {
clear: both;
font-weight: normal;
}
/* リストマーク なし*/
ol, ul {
list-style: none;
}
blockquote {
quotes: none;
}
blockquote:before, blockquote:after {
content: '';
content: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
/* リンクのある画像にボーダーを入れない*/
a img {
border: none;
}
2. レイアウト
次は大まかなレイアウトに関する部分です。
関係ありそうな記事はこちら
- Twenty Ten テーマの構成(レイアウト)-1
- Twenty Tenのレイアウトを変える(2)〜コンテンツ幅の調整
- Twenty Tenのレイアウトを変える(3)〜サイドバーを左にする
- Twenty Tenのレイアウトを変える(4)〜3カラムにする
- Twenty Tenのレイアウトを変える(5)〜コンテンツ中央の3カラムにする
- Twenty Tenのレイアウトを変える(6)〜1カラムにする
- Twenty Tenのレイアウトを変える子テーマ(CSSファイル)つくりました
/* =Layout
-------------------------------------------------------------- */
/*
LAYOUT: Two columns
DESCRIPTION: Two-column fixed layout with one sidebar right of content
*/
/* 2カラムにします 固定幅、右サイドバー */
#container {
float: left;
margin: 0 -240px 0 0;
width: 100%;
}
#content {
margin: 0 280px 0 20px;
}
#primary,
#secondary {
float: right;
overflow: hidden;
width: 220px;
}
#secondary {
clear: right;
}
#footer {
clear: both;
width: 100%;
}
/*
LAYOUT: One column, no sidebar
DESCRIPTION: One centered column with no sidebar
*/
/* 1カラム サイドバーなし コンテンツ幅 640px */
.one-column #content {
margin: 0 auto;
width: 640px;
}
/*
LAYOUT: Full width, no sidebar
DESCRIPTION: Full width content with no sidebar; used for attachment pages
*/
/* attachment pagees アタッチメントページ用 サイドバーなし */
.single-attachment #content {
margin: 0 auto;
width: 900px;
}
3. フォント
全体のフォントの設定です。使いたいフォントがあるときはこれを参考につけたしたりします。
/* =Fonts
-------------------------------------------------------------- */
/* 全体のフォントを変えるなら、ここ */
body,
input,
textarea,
.page-title span,
.pingback a.url {
font-family: Georgia, "Bitstream Charter", serif;
}
h3#comments-title,
h3#reply-title,
#access .menu,
#access div.menu ul,
#cancel-comment-reply-link,
.form-allowed-tags,
#site-info,
#site-title,
#wp-calendar,
.comment-meta,
.comment-body tr th,
.comment-body thead th,
.entry-content label,
.entry-content tr th,
.entry-content thead th,
.entry-meta,
.entry-title,
.entry-utility,
#respond label,
.navigation,
.page-title,
.pingback p,
.reply,
.widget-title,
.wp-caption-text,
input[type=submit] {
font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
}
pre {
font-family: "Courier 10 Pitch", Courier, monospace;
}
code {
font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
}
4. Structure 基本構造
レイアウト部分より少し細かい部分のレイアウトがこちらにあります。なぜかフッターウィジェットとコピーライトなどもこちらに。
/* =Structure
-------------------------------------------------------------- */
/* The main theme structure */
/* 全体幅 */
#access .menu-header,
div.menu,
#colophon,
#branding,
#main,
#wrapper {
margin: 0 auto;
width: 940px;
}
/* 全体の囲み */
#wrapper {
background: #fff;
margin-top: 20px;
padding: 0 20px;
}
/* Structure the footer area */
/*----フッターエリアの部品---- */
/* フッターウィジェット */
#footer-widget-area {
overflow: hidden;
}
/* フッターウィジェット 左にfloat 幅220px */
#footer-widget-area .widget-area {
float: left;
margin-right: 20px;
width: 220px;
}
/* フッターウィジェット 4番目は右マージンなし*/
#footer-widget-area #fourth {
margin-right: 0;
}
/* サイトインフォ コピーライト 左にfloat */
#site-info {
float: left;
font-size: 14px;
font-weight: bold;
width: 700px;
}
/* Proudly powered by WordPress. 右にfloat */
#site-generator {
float: right;
width: 220px;
}
5. Global Elements
基本的な要素の設定がここでされています。全部ではないのですが、変更したくなりそうな部分にざっとコメント入れています。
/* =Global Elements
-------------------------------------------------------------- */
/* Main global 'theme' and typographic styles */
/* body背景色 */
body {
background: #f1f1f1;
}
body,
input,
textarea {
color: #666;
font-size: 12px;
line-height: 18px;
}
/* 区切り線 */
hr {
background-color: #e7e7e7;
border: 0;
clear: both;
height: 1px;
margin-bottom: 18px;
}
/* Text elements */
/* 段落 マージン */
p {
margin-bottom: 18px;
}
/* リスト リストマーク、マージン */
ul {
list-style: square;
margin: 0 0 18px 1.5em;
}
/* 順序ありリスト リストマーク、マージン */
ol {
list-style: decimal;
margin: 0 0 18px 1.5em;
}
ol ol {
list-style: upper-alpha;
}
ol ol ol {
list-style: lower-roman;
}
ol ol ol ol {
list-style: lower-alpha;
}
ul ul,
ol ol,
ul ol,
ol ul {
margin-bottom: 0;
}
/* 定義リスト */
dl {
margin: 0 0 24px 0;
}
dt {
font-weight: bold;
}
dd {
margin-bottom: 18px;
}
/* 強調 */
strong {
font-weight: bold;
}
cite,
em,
i {
font-style: italic;
}
big {
font-size: 131.25%;
}
ins {
background: #ffc;
text-decoration: none;
}
blockquote {
font-style: italic;
padding: 0 3em;
}
blockquote cite,
blockquote em,
blockquote i {
font-style: normal;
}
pre {
background: #f7f7f7;
color: #222;
line-height: 18px;
margin-bottom: 18px;
padding: 1.5em;
}
abbr,
acronym {
border-bottom: 1px dotted #666;
cursor: help;
}
sup,
sub {
height: 0;
line-height: 1;
position: relative;
vertical-align: baseline;
}
sup {
bottom: 1ex;
}
sub {
top: .5ex;
}
input[type="text"],
textarea {
background: #f9f9f9;
border: 1px solid #ccc;
box-shadow: inset 1px 1px 1px rgba(0,0,0,0.1);
-moz-box-shadow: inset 1px 1px 1px rgba(0,0,0,0.1);
-webkit-box-shadow: inset 1px 1px 1px rgba(0,0,0,0.1);
padding: 2px;
}
/* リンクカラー */
a:link {
color: #0066cc;
}
a:visited {
color: #743399;
}
a:active,
a:hover {
color: #ff4b33;
}
/* Text meant only for screen readers */
/* スクリーンリーダー用テキスト */
.screen-reader-text {
position: absolute;
left: -9000px;
}
6. ヘッダー
ヘッダー部分です。サイトのタイトルや説明、メインイメージなどが設定されています。
関係ありそうな記事はこちら
- Twenty Tenテーマのヘッダー部分のデザイン変更(1)〜サイトのロゴをいれてみる
- Twenty Tenテーマのヘッダー部分のデザイン変更(2)〜サイトサマリーの調整
- Twenty Tenテーマのヘッダー部分のデザイン変更(2)〜メインイメージ
- Twenty Tenテーマでページごとにヘッダーの画像を変える
/* =Header
-------------------------------------------------------------- */
#header {
padding: 30px 0 0 0;
}
/* サイトのタイトル
左フロート(幅)700px フォントサイズと行の高さ 下マージン*/
#site-title {
float: left;
font-size: 30px;
line-height: 36px;
margin: 0 0 18px 0;
width: 700px;
}
/* サイトのタイトル リンク
フォントカラー、太さ、装飾*/
#site-title a {
color: #000;
font-weight: bold;
text-decoration: none;
}
/* サイトの説明
右フロート(幅)220px フォントスタイル マージン*/
#site-description {
clear: right;
float: right;
font-style: italic;
margin: 14px 0 18px 0;
width: 220px;
}
/* This is the custom header image
ヘッダーの画像 上下にボーダー */
#branding img {
border-top: 4px solid #000;
border-bottom: 1px solid #000;
clear: both;
display: block;
}
7. グローバルナビ
サイトのメインのナビゲーションです。ドロップダウンメニューになるよう設定されています。
関係ありそうな記事はこちら
/* =Menu
-------------------------------------------------------------- */
/*グローバルナビのエリア */
#access {
background: #000;
display: block;
float: left;
margin: 0 auto;
width: 940px;
}
/*グローバルナビ */
#access .menu-header,
div.menu {
font-size: 13px;
margin-left: 12px;
width: 928px;
}
/*グローバルナビ リスト リストマークを消す マージン0 */
#access .menu-header ul,
div.menu ul {
list-style: none;
margin: 0;
}
/*グローバルナビ リスト floatさせる*/
#access .menu-header li,
div.menu li {
float: left;
position: relative;
}
/*グローバルナビ リンク */
#access a {
color: #aaa;
display: block;
line-height: 38px;
padding: 0 10px;
text-decoration: none;
}
/*グローバルナビ ドロップダウン*/
#access ul ul {
box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
display: none;
position: absolute;
top: 38px;
left: 0;
float: left;
width: 180px;
z-index: 99999;
}
#access ul ul li {
min-width: 180px;
}
#access ul ul ul {
left: 100%;
top: 0;
}
#access ul ul a {
background: #333;
line-height: 1em;
padding: 10px;
width: 160px;
height: auto;
}
#access li:hover > a,
#access ul ul :hover > a {
background: #333;
color: #fff;
}
#access ul li:hover > ul {
display: block;
}
#access ul li.current_page_item > a,
#access ul li.current-menu-ancestor > a,
#access ul li.current-menu-item > a,
#access ul li.current-menu-parent > a {
color: #fff;
}
* html #access ul li.current_page_item a,
* html #access ul li.current-menu-ancestor a,
* html #access ul li.current-menu-item a,
* html #access ul li.current-menu-parent a,
* html #access ul li a:hover {
color: #fff;
}
8. コンテンツ
コンテンツ部分です。なるべく細かくコメントを入れてみたつもりです。
関係ありそうな記事はこちら
- 記事ごとにCSSをわりあてる(記事固有のid)〜Twenty Ten メイン部分のCSSカスタマイズ(2)
- 変化するentry-title(記事タイトル)〜Twenty Ten メイン部分のCSSカスタマイズ(3)
- 投稿日にアイコンをつける(entry-meta)〜Twenty Ten メイン部分のCSSカスタマイズ(4)
- 記事本文(entry-content)〜Twenty Ten メイン部分のCSSカスタマイズ(5)
- 「続きを読む」のCSS〜Twenty Ten メイン部分のCSSカスタマイズ(6)
- 記事下のカテゴリーなどへのリンク(entry-utility)〜Twenty Ten メイン部分のCSSカスタマイズ(7)
/* =Content
-------------------------------------------------------------- */
/* #content 基本のテキストカラー、サイズ、行の高さ */
#content,
#content input,
#content textarea {
color: #333;
font-size: 16px;
line-height: 24px;
}
/* #content 段落やリストなどの下マージン */
#content p,
#content ul,
#content ol,
#content dd,
#content pre,
#content hr {
margin-bottom: 24px;
}
/* #content 入れ子になっているリスト(子)の下マージン */
#content ul ul,
#content ol ol,
#content ul ol,
#content ol ul {
margin-bottom: 0;
}
/* #content pre などのフォントサイズと行間 */
#content pre,
#content kbd,
#content tt,
#content var {
font-size: 15px;
line-height: 21px;
}
/* #content code のフォントサイズ */
#content code {
font-size: 13px;
}
/* #content dt,thのフォントカラー */
#content dt,
#content th {
color: #000;
}
/* #content h1〜h6のカラー、行の高さ、下マージン */
#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6 {
color: #000;
line-height: 1.5em;
margin: 0 0 20px 0;
}
/* #content table 関係の設定*/
#content table {
border: 1px solid #e7e7e7; /* ボーダー*/
margin: 0 -1px 24px 0;
text-align: left;
width: 100%;
}
/*table th*/
#content tr th,
#content thead th {
color: #888; /*フォントカラー*/
font-size: 12px; /*フォントサイズ*/
font-weight: bold;
line-height: 18px;
padding: 9px 24px;
}
/*table td*/
#content tr td {
border-top: 1px solid #e7e7e7;
padding: 6px 24px;
}
#content tr.odd td {
background: #f2f7fc;
}
/* #content .hentry の下マージン */
.hentry {
margin: 0 0 48px 0;
}
/* 先頭固定記事 背景色 上ボーダーなど */
.home .sticky {
background: #f2f7fc;
border-top: 4px solid #000;
margin-left: -20px;
margin-right: -20px;
padding: 18px 20px;
}
/* #content シングルページの.hentry 下マージン */
.single .hentry {
margin: 0 0 36px 0;
}
/* #content カテゴリー、タグ、アーカイブなどの一覧ページのタイトル */
.page-title {
color: #000;
font-size: 14px;
font-weight: bold;
margin: 0 0 36px 0;
}
/* 一覧ページのタイトル span*/
.page-title span {
color: #333;
font-size: 16px;
font-style: italic;
font-weight: normal;
}
/* 一覧ページのタイトル 未訪問リンク,訪問済みリンク*/
.page-title a:link,
.page-title a:visited {
color: #888;
text-decoration: none;
}
/* 一覧ページのタイトル アクティブ,マウスオーバー */
.page-title a:active,
.page-title a:hover {
color: #ff4b33;
}
/* #content 記事タイトルのフォンとカラーやサイズなど */
#content .entry-title {
color: #000;
font-size: 21px;
font-weight: bold;
line-height: 1.3em;
margin-bottom: 0;
}
/* #content 記事タイトル 未訪問リンク,訪問済みリンク */
.entry-title a:link,
.entry-title a:visited {
color: #000;
text-decoration: none;
}
/* #content 記事タイトル アクティブ,マウスオーバー */
.entry-title a:active,
.entry-title a:hover {
color: #ff4b33;
}
/* #content .entry-metaのフォントカラーとサイズ */
.entry-meta {
color: #888;
font-size: 12px;
}
/* #content .entry-metaと.entry-utilityの abbr */
.entry-meta abbr,
.entry-utility abbr {
border: none;
}
.entry-meta abbr:hover,
.entry-utility abbr:hover {
border-bottom: 1px dotted #666;
}
/* #content 記事本文 左に余白*/
.entry-content,
.entry-summary {
clear: both;
padding: 12px 0 0 0;
}
/* #content 記事抜粋 */
#content .entry-summary p:last-child {
margin-bottom: 12px;
}
/* #content 記事本文 fieldset */
.entry-content fieldset {
border: 1px solid #e7e7e7;
margin: 0 0 24px 0;
padding: 24px;
}
.entry-content fieldset legend {
background: #fff;
color: #000;
font-weight: bold;
padding: 0 24px;
}
/* #content 記事本文 input */
.entry-content input {
margin: 0 0 24px 0;
}
.entry-content input.file,
.entry-content input.button {
margin-right: 24px;
}
/* #content 記事本文 label */
.entry-content label {
color: #888;
font-size: 12px;
}
/* #content 記事本文 select */
.entry-content select {
margin: 0 0 24px 0;
}
.entry-content sup,
.entry-content sub {
font-size: 10px;
}
/* #content 記事本文 blockquote の.left*/
.entry-content blockquote.left {
float: left;
margin-left: 0;
margin-right: 24px;
text-align: right;
width: 33%;
}
/* #content 記事本文 blockquote の.right */
.entry-content blockquote.right {
float: right;
margin-left: 24px;
margin-right: 0;
text-align: left;
width: 33%;
}
/* 記事を分割表示 */
.page-link {
color: #000;
font-weight: bold;
margin: 0 0 22px 0;
word-spacing: 0.5em;
}
/* 記事を分割表示 未訪問リンク,訪問済みリンク */
.page-link a:link,
.page-link a:visited {
background: #f1f1f1;
color: #333;
font-weight: normal;
padding: 0.5em 0.75em;
text-decoration: none;
}
/* 分割表示下記事を先頭固定 */
.home .sticky .page-link a {
background: #d9e8f7;
}
/* 記事を分割表示 アクティブ,マウスオーバー */
.page-link a:active,
.page-link a:hover {
color: #ff4b33;
}
/* #content 記事編集 のリンク*/
body.page .edit-link {
clear: both;
display: block;
}
/* #content 作者プロフィール */
#entry-author-info {
background: #f2f7fc;
border-top: 4px solid #000;
clear: both;
font-size: 14px;
line-height: 20px;
margin: 24px 0;
overflow: hidden;
padding: 18px 20px;
}
/*作者プロフィール アバター*/
#entry-author-info #author-avatar {
background: #fff;
border: 1px solid #e7e7e7;
float: left;
height: 60px;
margin: 0 -104px 0 0;
padding: 11px;
}
/*作者プロフィール 説明*/
#entry-author-info #author-description {
float: left;
margin: 0 0 0 104px;
}
/*作者プロフィール 作者名+*/
#entry-author-info h2 {
color: #000;
font-size: 100%;
font-weight: bold;
margin-bottom: 0;
}
/* #content .entry-utility フォントカラー、サイズ、行の高さなど */
.entry-utility {
clear: both;
color: #888;
font-size: 12px;
line-height: 18px;
}
/* #content .entry-metaと.entry-utility リンク フォントカラー */
.entry-meta a,
.entry-utility a {
color: #888;
}
/* #content .entry-metaと.entry-utility hoverカラー*/
.entry-meta a:hover,
.entry-utility a:hover {
color: #ff4b33;
}
#content .video-player {
padding: 0;
}
長かった...
行数で見てもだいたいここまでで半分、という感じですね。改めて、こんなにあるのでは探すの大変だなあ、と思います。
この記事が少しでもお役に立ちますように。
あ!くれぐれもTwenty Ten本体のCSSを書き換えずに子テーマをつくってそこに書いて下さいね。
古い記事への質問で申し訳ございません。
こちらの記事を参考にしながら「Twenty Ten」のカスタマイズをしています。
そのなかでどうしても自分の力でできなっかた点を質問させてください。
記事(投稿)と記事との間隔(新しい投稿のカテゴリーやコメントの部分から、古い投稿のタイトルまでの間隔)
を広げたいと思っているのですが、どうしてもうまくいきません。
なにか方法がございましたらご教授いただけると幸いです。
ユウスケ さん
記事(投稿)と記事との間隔というのは、例えばトップページなど記事の一覧があって、
その記事と記事の間のことでしょうか。
それでしたら、Twenty Tenのデフォルトで、
.hentry {
margin: 0 0 48px 0;
}
と設定されています。これは記事の囲みについているクラス名の一つですので
この 48pxを変えてあげればよいと思います。
.post でも同じ形になるはずです。
場所が違いましたらまたコメント下さいね
日本におけるTwenty Tenのカスタマイズで、このサイトほど詳細に解説されているところは他になく、いつも参考にさせていただいています。
メニュー幅について質問させてください。
メニューによってHeaderとContentを上下分離するような形(width: 940pxから無限)にしたいのですが、どの値を変更すれば良いかご教授いただけないでしょうか。
子テーマに↓のように記述して、続きがわかりませんでした。。
/* =Menu
————————————————————– */
#access {
background: url(./images/menu-line.gif) repeat-x left bottom;
}
トモ さん
ブログを読んでいただけてうれしいです。
おたずねの件、いつか取りあげたいと思っていた事でもありましたので、今日の記事にしました。
これでうまくいくといいですが。。