Twenty Eleven グローバルナビゲーションのカスタマイズ

ワードプレステーマTwentyElevenのグローバルナビゲーションのカスタマイズの方法です。

当サイト一押しのテーマです(笑 と言いますのも、そんなにたくさんではありませんが、色々なテーマを使ってみてやっぱり使いやすい。

また、カスタマイズもしやすいと思います。そして、初心者の方にとっても扱いやすいテーマだと感じます。Twelveも良いのですが、チョッと難しいのが難点。

話がソレましたね。ElevenのグローバルナビゲーションはGoodです!!デフォルトでもすでにグラデーションが施されています!!ですから、カラーコードを変更するだけでもかなり見栄えの良いグローバルナビゲーションになってしまいます。

あっ、ちなみに、IEからですと残念ながら単色表示になってしまいます。オススメのブラウザはコチラを参照してみて下さい。

さて、それでは、TwentyElevenのグローバルナビゲーションをカスタマイズしていきましょう♫ チョッと長目になりますがお許し下さい…。

Elevevのグローバルナビはこうしてカスタマイズする!!

それでは、管理画面より「外観」⇒「テーマ編集」から’スタイルシート’を開いて下さい。(小テーマを使用している方は、小テーマ側のスタイルシートを編集して下さい)

スタイルシートの中から、次の部分を探して下さい。

/* =Menu
-------------------------------------------------------------- */

#access {
	background: #222; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#252525, #0a0a0a);
	background: -o-linear-gradient(#252525, #0a0a0a);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#252525), to(#0a0a0a)); /* older webkit syntax */
	background: -webkit-linear-gradient(#252525, #0a0a0a);
	-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	clear: both;
	display: block;
	float: left;
	margin: 0 auto 6px;
	width: 100%;
}
#access ul {
	font-size: 13px;
	list-style: none;
	margin: 0 0 0 -0.8125em;
	padding-left: 0;
}
#access li {
	float: left;
	position: relative;
}
#access a {
	color: #eee;
	display: block;
	line-height: 3.333em;
	padding: 0 1.2125em;
	text-decoration: none;
}
#access ul ul {
	-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
	-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
	box-shadow: 0 3px 3px rgba(0,0,0,0.2);
	display: none;
	float: left;
	margin: 0;
	position: absolute;
	top: 3.333em;
	left: 0;
	width: 188px;
	z-index: 99999;
}
#access ul ul ul {
	left: 100%;
	top: 0;
}
#access ul ul a {
	background: #f9f9f9;
	border-bottom: 1px dotted #ddd;
	color: #444;
	font-size: 13px;
	font-weight: normal;
	height: auto;
	line-height: 1.4em;
	padding: 10px 10px;
	width: 168px;
}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
	background: #efefef;
}
#access li:hover > a,
#access a:focus {
	background: #f9f9f9; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
	background: -o-linear-gradient(#f9f9f9, #e5e5e5);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
	background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
	color: #373737;
}
#access ul li:hover > ul {
	display: block;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a {
	font-weight: bold;
}

これが、デフォルトのスタイルシートです。それぞれの箇所(カラーコード)などを変更すれば、それなりにカスタマイズ出来てしまいます。

当サイトを例にカスタマイズしてみましょう。以下の様に追加/編集すると、当サイトのグローバルナビの表示になります。

/* =Menu
-------------------------------------------------------------- */

#access { /* グローバルナビの背景設定 */
	background: #505050; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#505050, #232323);
	background: -o-linear-gradient(#505050, #232323);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#505050), to(#232323)); /* older webkit syntax */
	background: -webkit-linear-gradient(#505050, #232323);
	-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	box-shadow: rgba(0, 0, 0, 0.8) 0px 1px 2px;
	-moz-border-radius:2px;
        -webkit-border-radius:2px;
        -khtml-border-radius:2px;
        border-radius:2px;
	clear: both;
	display: block;
	color: #fefefe;
	float: left;
	margin: 0 auto 6px;
	width: 100%;
}
#access ul { /* グローバルナビのメニュー文字設定 */
	font-size: 14px;
	color: #fefefe;
	list-style: none;
	margin: 0 0 0 -4.5125em;  /* メニュー開始部分を左寄せ */
	padding-left: 0;
}
#access li {
	float: left;
	position: relative;
}
#access a { /* グローバルナビのメニュー文字設定(リンク色) */
	font-family:'ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'MS Pゴシック',sans-serif;
	color: #fefefe;
	display: block;
	line-height: 3em;  /* グローバルナビの高さ */
	padding: 0 0.8125em;  /* メニュー文字の行間(横の距離) */
	text-decoration: none;
}
#access ul ul { /* メニューの階層表示2段目 */
	background: #f0fafa; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#f0fafa, #c5d1d1);
	background: -o-linear-gradient(#f0fafa, #c5d1d1);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f0fafa), to(#c5d1d1)); /* older webkit syntax */
	background: -webkit-linear-gradient(#f0fafa, #c5d1d1);
	-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	box-shadow: rgba(0, 0, 0, 0.8) 0px 1px 2px;
	-moz-border-radius:2px;
        -webkit-border-radius:2px;
        -khtml-border-radius:2px;
        border-radius:2px;
	display: none;
	float: left;
	margin: 0;
	position: absolute;
	top: 3em;
	left: 0;
	width: 168px;
	z-index: 99999;
}
#access ul ul ul {  /* メニューの階層表示3段目 */
	left: 100%;
	top: 0;
	width: 200px;
}
#access ul ul a { /* グローバルナビ 階層表示 メニュー文字などの設定  */
	background: #c5d1d1;
	background: #f0fafa; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#f0fafa, #c5d1d1);
	background: -o-linear-gradient(#f0fafa, #c5d1d1);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f0fafa), to(#c5d1d1)); /* older webkit syntax */
	background: -webkit-linear-gradient(#f0fafa, #c5d1d1);
	-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
	box-shadow: rgba(0, 0, 0, 0.8) 0px 1px 2px;
	-moz-border-radius:2px;
        -webkit-border-radius:2px;
        -khtml-border-radius:2px;
        border-radius:2px;
	color: #cf9469;
	font-size: 14px;
	font-weight: normal;
	height: auto;
	line-height: 1.4em;
	padding: 10px 10px;
	width: 192px;
}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {  /* メニュー階層表示 マウスオーバー時の色変更 */
	background: #fefefe; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#fefefe, #dfdfdf);
	background: -o-linear-gradient(#fefefe, #dfdfdf);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fefefe), to(#dfdfdf)); /* older webkit syntax */
	background: -webkit-linear-gradient(#fefefe, #dfdfdf);
}
#access li:hover > a,
#access a:focus { /* グローバルナビ マウスオーバー時の背景及び文字色の設定 */
	background: #afdbdb; /* Show a solid color for older browsers */
	background: -moz-linear-gradient(#f5fafa, #afdbdb);
	background: -o-linear-gradient(#f5fafa, #afdbdb);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f5fafa), to(#cafdbdb)); /* Older webkit syntax */
	background: -webkit-linear-gradient(#f5fafa, #afdbdb);
	-moz-border-radius:3px;
        -webkit-border-radius:3px;
        -khtml-border-radius:3px;
        border-radius:3px;
	color: #612500;
	font-weight: bold;
}
#access ul li:hover > ul {
	display: block;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a { /* 滞在ページのメニュー文字の表示設定 */
	font-weight: bold;
}

それぞれの項目に’注釈’を添えてみました。青色の部分は追加部分で、表示メニューの角の部分に少し丸みを付けています。丸みが要らない方は、追加しなければOKです。

また、グラデーションを施したくない、単色表示がしたいって方は、’background: -xxxx-gradient’の部分を全て撤去すれば単色表示になります。

なおグラデーション表示は、4箇所の’background: -xxxx-gradient’のカラーコードを入力(4箇所全て同じ数値に統一すること)すればOK。左側の数値が始点で右側の数値が終点になります。それに沿って、自動でグラデーションが施されますので超ベンリです!!

それから、’margin’’padding’の値を変える事でメニュー文字の全体の表示位置やテキスト間(メニュー文字と文字の間)の距離などを変更する事が出来ます。お好みの数値を入力してみて下さい。

少し長くなりましたが、これでグローバルメニューの表示が変わったハズです。色やサイズなどは、色々と試してみて下さいね☆



にほんブログ村 ブログブログ ブログノウハウへ

2 thoughts on “Twenty Eleven グローバルナビゲーションのカスタマイズ

  1. ピンバック: CSS3がマジですごい件 | 初めてのワードプレス カスタマイズ

  2. ピンバック: TwentyEleven グローバルナビゲーションの幅調整(縦/横) | 初めてのワードプレス カスタマイズ

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です