MoonNote

はてなブログテーマ / CSS / jQuery

はてなブログテーマ「Innocent」のカスタマイズ(続きを読むボタン編)

f:id:waitingmoon:20160115111009j:plain

続きを読むボタンのデザインを変更したいとのコメントを頂いたので、いくつかのサンプルを掲載したいと思います。掲載しているサンプルは全て Innocent 用になりますが、コードを一部修正すれば Blank やその他のはてなブログテーマでも使用可能です。

基本CSS

.entry-content .entry-see-more {
    background-color: #222;
    border-radius: 2px;
    box-sizing: border-box;
    color: rgba(255, 255, 255, 0.9);
    display: inline-block;
    font-size: 0.875em;
    line-height: 44px; /* Button height */
    min-width: 176px; /* Button width */
    text-align: center;
    text-decoration: none;
}

.entry-content .entry-see-more:hover {
    background-color: #555;
    color: rgba(255, 255, 255, 0.9);
}

上記のコードは Innocent の標準の続きを読むボタンに指定している CSS です。以下に掲載するサンプルは全てこのコードをベースにカスタマイズしたものになります。改めて書きますが、コードを一部修正すれば Blank やその他のはてなブログテーマでも使用可能です。

サンプル

注意

掲載しているサンプルは全て実動します。ボタンをマウスオーバーして hover 時のデザインをご確認ください。

1. 背景色変更

続きを読む

.entry-content .entry-see-more {
    background-color: #6cc655;
}

.entry-content .entry-see-more:hover {
    background-color: #6cc655;
    opacity: 0.7;
}

ボタンの色(背景色)は background-color で変更できます。マウスオーバー時に少し薄くなる動作は opacity で透明度を高めることで実現しています。

2. 背景色・文字色変更

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    background-color: #e6e6e6;
    color: rgba(0, 0, 0, 0.9);
}

.entry-content .entry-see-more:hover {
    background-color: #222;
    color: rgba(255, 255, 255, 0.9);
}

#e6e6e6 のように白に近い背景色を指定するときは、文字色を color: rgba(0, 0, 0, 0.9)(黒)に変更した方が良いでしょう。

3. 背景色変更(グラデーション)

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    background-color: #555;
    background-image: -webkit-linear-gradient(#555, #222);
    background-image: linear-gradient(#555, #222);
}
.entry-content .entry-see-more:hover {
    background-color: #555;
    opacity: 0.9;
}

background-image に linear-gradient(開始色, 終了色) を指定するとボタンの色がグラデーションに変わります。linear-gradient に対応していないブラウザ(古いIEなど)では background-color が適用されるので注意して下さい。

4. マウスオーバーで中抜き

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    background-color: #222;
    border: 2px solid #222;
    line-height: 40px;
}

.entry-content .entry-see-more:hover {
    background-color: transparent;
    color: #222;
}

background-color と border-color に同じ色を指定して、hover では背景色のみを透明化するように指定すると、マウスオーバーした時に中が抜けます。

5. マウスオーバーで中埋め

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    background-color: transparent;
    border: 2px solid #222;
    color: #222;
    line-height: 40px;
}

.entry-content .entry-see-more:hover {
    background-color: #222;
    color: rgba(255, 255, 255, 0.9);
}

4 の逆バージョンです。

6. 影をつける

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

box-shadow ではボタンに影をつけられます。指定の順番は X軸のずれ Y軸のずれ ぼかし半径 色 です。

7. 影をつける(内側)

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    background-color: #03a9f4;
    box-shadow: 0 -3px 0 rgba(0,0,0,0.18) inset;
}

.entry-content .entry-see-more:hover {
    background-color: #03a9f4;
    opacity: 0.7;
}

insetbox-shadow を指定すると立体的なボタンを作ることが出来ます。

8. アイコンを表示

デモ

続きを読む

CSS

.entry-content .entry-see-more::before {
    content: "\f0a9";
    display: inline-block;
    font-family: FontAwesome;
    margin-right: 7px;
}

::before 擬似要素で「続きを読む」の前にアイコンを表示するデザインです。margin-right はアイコンと「続きを読む」の間隔になります。

表示できるアイコンの一覧と対応する番号 \f*** は以下のページを参照して下さい。

fortawesome.github.io

9. アイコンを表示・マウスオーバー時にアイコンをずらす

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    background-color: #222;
}

.entry-content .entry-see-more:hover {
    background-color: #222;
}

.entry-content .entry-see-more::before {
    background-color: #222;
    content: "\f0a9";
    display: inline-block;
    font-family: FontAwesome;
    margin-right: 7px;
    -webkit-transition: all .3s ease;
    transition: all .3s ease;
    position: relative;
    left: 0;
}

.entry-content .entry-see-more:hover::before {
    left: 2px;
}

hover をボタンの透明度ではなく、アイコンをずらすことで確認するデザインです。

10. 文字列を変更

デモ

続きを読む

CSS

.entry-content .entry-see-more {
    font-size: 0;
}

.entry-content .entry-see-more::before {
    content: "Read More";
    display: inline-block;
    font-size: 14px;
    vertical-align: middle;
}

文字列を変更するには font-size: 0 で「続きを読む」を無理やり消した後、擬似要素で文字を挿入します。英語が好きなんだよという方に。

まとめ

似たようなデザインがいくつかある気がしますが、とりあえずよく見かけるものをまとめてみました。

続きを読む以外にも、こういうカスタマイズ記事を書いて欲しい!という方がいましたら、記事へのコメントまたは @h_a_l_f へのリプライ/ダイレクトメッセージでお気軽にお知らせ下さい。