意外と役に立つ、応用の効きやすいパンクズリストのサンプルです。
Font Awesomeの矢印を:before擬似要素を使って表示することで、HTMLがスッキリします。
contentプロパティに使いたいアイコンフォントを入れることで、
ちょっとデザインを変更するのにわざわざ画像を作り直したりすることもなくなり、
cssの変更だけで楽チン簡単更新です。
パンくずリスト(breadcrumb list)は、ウェブサイト内でのウェブページの位置を、ツリー構造を持ったハイパーリンクの一覧として示すもの。パンくずナビ、トピックパス、フットパスとも言う。英語では単に“breadcrumbs”または“breadcrumb navigation”というのが一般的である。
ウェブディレクトリのような大規模なウェブサイト内で、利用者がサイト内での現在位置を見失わないようにし、ナビゲーションを助けるために使われる。「パンくずリスト」という名前は、童話『ヘンゼルとグレーテル』で、主人公が森で迷子にならないように通り道にパンくずを置いていった、というエピソードに由来する。
wikiより引用
使用するclass名
.topicPath
View
Source
1 2 3 4 5 6 7 | <div class="topicPath"> <ol> <li><a href="/">ホーム</a></li> <li><a href="#">親ページ</a></li> <li>子ページ</li> </ol> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | .topicPath { clear: both; line-height: 1; width: 100%; max-width: 960px; margin: 0 auto; } .topicPath ol { display: inline-block; text-align: left; } .topicPath ol li { display: inline-block; font-size: 11px; } .topicPath ol li:before { content: "\f105"; display: inline-block; padding: 0 0.5em; font-family: FontAwesome; } .topicPath ol li:first-child:before { display: none; } .topicPath ol li a { color: #666; text-decoration: none; } @media print, screen and (min-width: 768px) { .topicPath ol li a:hover { text-decoration: underline; } } @media screen and (max-width: 767px) { } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | //リンクサイズ @mixin topicPath_text_size { font-size:$base_text_size - 3px; } //マウスアクション(normal) @mixin topicPath_action_normal { color:$text_color; text-decoration:none; } //マウスアクション(hover) @mixin topicPath_action_hover { text-decoration:underline; } //表示設定 $topicPath_display_pc :block; $topicPath_display_sp :none; .topicPath { clear:both; line-height:1; width:100%; max-width: $site_width; margin:0 auto; ol { display:inline-block; text-align:left; li { display:inline-block; @include topicPath_text_size; &:before { content:"\f105"; display:inline-block; padding:0 0.5em; font-family:$icon_font; } &:first-child:before { display:none; } a { @include topicPath_action_normal; } } } } @media print, screen and (min-width: 768px){ .topicPath { display:$topicPath_display_pc; a { &:hover { @include topicPath_action_hover; } } } } @media screen and (max-width: 767px){ .topiPath { display:$topicPath_display_sp; padding:0 $site_side_margin; } } |