Minimal Green

はてなブログテーマ『Minimal Green』のデモブログ。はてなブログカスタマイズや、HTML、CSSなどについて書いています。

記事下にCTAを設置するカスタマイズ

f:id:minimalgreen:20180808202614j:plain
記事下にCTAを設置するカスタマイズを作りましたのでご紹介します。WordPressの有料テーマではよく見かけますね。このカスタマイズははてなブログはもちろん、WordPress、その他のブログサービスでも使えます。

CTAとは

CTAとは「CTA(Call To Action:コールトゥアクション)」の略でWebページ上でユーザーにクリックしてもらうなど行動を起こさせるためのボタンや画像・テキストを意味します。
例えばはてなブログのトップページで言うと
f:id:minimalgreen:20180808194508p:plain
この「はてなブログとは」の緑色のボタンがCTAです。
webサイトを作るとき、ユーザーに商品を購入してほしい、お問い合わせしてほしい、など何かしらの目的がある場合が多いと思います。そうしたPRしたいものを訴求し、コンバージョンへ結びつけるのがCTAです。
ferret-plus.com

    • お問い合わせ
    • 商品購入
    • メルマガ登録
    • 資料請求

などがCTAの対象になりやすいです。今なら「Note購入」などもCTAになりそうですね。アフィリエイトリンクに使っても良いと思いますし、一番PRしたいことをCTAに入れると良いと思います。

見た目はこんな感じ

自分のはてなブログテーマを対象としてCTAを作ってみました。
PC版
f:id:minimalgreen:20180808195341p:plain
スマートフォン版
f:id:minimalgreen:20180808195400p:plain
レスポンシブデザインでスマートフォンに対応しています。レスポンシブデザインではないスマートフォン版を使っている場合もそのままコードをスマートフォン版の記事下に入れてもらえば使えます。

カスタマイズコード

HTML(記事下)

デザイン>カスタマイズ>記事下のところに以下のコードを入れて下さい。内容は適宜変えてください。

<div class="cta-container">
<div class="cta-left center">
<img src="画像URL" alt="CTA画像">
</div>
<div class="cta-right center">
<div class="cta-description">
ここに説明文を入れます。
</div>
<a class="cta-btn" href="ボタンのリンク先URL" target=""><i class="fa fa-file-text fa-fw" aria-hidden="true"></i>CTAボタン</a>
</div>
</div>

CSS

デザインCSSに以下のコードを追記してください。色などは適宜変えてください。

/*  はてなブログ共通CSSで記述済み */
.center {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}
/*  CTAデザイン */
.cta-container img {
    width: 100%;
    max-width: 100%!important;
    height: auto!important;
}
.cta-container {
    background-color: #555;/* CTA背景色 */
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: center;
    justify-content: center;
    padding: 30px;
    box-sizing: border-box;
    margin-top: 20px;
}

.cta-left {
    position: relative;
    width: calc(50% - 20px);
    text-align: center;
    margin-right: 20px;
}

.cta-right {
    color: #fff;
    font-size: 16px;
    width: 50%;
}

.cta-description {
    color: #fff;/* 説明文文字色 */
    padding: 10px;
    text-align: left;
}

@media only screen and (max-width: 1023px) {
    .cta-container {
        padding: 10px;
    }
}

@media only screen and (max-width: 767px) {
    .cta-container {
        display: block;
        padding: 20px;
    }
    .cta-right, .cta-left {
        width: 100%;
    }
}


/* CTAボタン */

.cta-btn {
    display: inline-block;
    padding: 1em 1em;
    text-decoration: none!important;
    background-color: #db4a39;/*ボタン色*/
    color: #fff!important;
    border-bottom: solid 4px #a92d1f;/* 影の色 */
    border-radius: 8px;
}
.cta-btn:hover {
    background-color: #e37164;/* マウスホバー時 */
}
.cta-btn:active {
    -ms-transform: translateY(4px);
    -webkit-transform: translateY(4px);
    transform: translateY(4px);
    border-bottom: none;
}

スマートフォン用

レスポンシブではないはてなブログ独自のスマートフォン版をご使用の方は以下のコードをそのまま記事下に入れて下さい。

<div class="cta-container">
<div class="cta-left center">
<img src="画像URL" alt="CTA画像">
</div>
<div class="cta-right center">
<div class="cta-description">
ここに説明文を入れます。
</div>
<a class="cta-btn" href="ボタンのリンク先URL" target=""><i class="fa fa-file-text fa-fw" aria-hidden="true"></i>CTAボタン</a>
</div>
</div>
<style>
/* CTA */

.cta-container img {
    width: 100%;
    max-width: 100%!important;
    height: auto!important;
}

.cta-container {
    background-color: #555;/* CTA背景色 */
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: center;
    justify-content: center;
    padding: 30px;
    box-sizing: border-box;
    margin-top: 20px;
}

.cta-left {
    position: relative;
    width: calc(50% - 20px);
    text-align: center;
    margin-right: 20px;
}

.cta-right {
    color: #fff;
    font-size: 16px;
    width: 50%;
}

.cta-description {
    color: #fff;/* 説明文文字色 */
    padding: 10px;
    text-align: left;
}

@media only screen and (max-width: 1023px) {
    .cta-container {
        padding: 10px;
    }
}

@media only screen and (max-width: 767px) {
    .cta-container {
        display: block;
        padding: 20px;
    }
    .cta-right, .cta-left {
        width: 100%;
    }
}


/* CTAボタン */

.cta-btn {
    display: inline-block;
    padding: 1em 1em;
    text-decoration: none!important;
    background-color: #db4a39;/*ボタン色*/
    color: #fff!important;
    border-bottom: solid 4px #a92d1f;/* 影の色 */
    border-radius: 8px;
}
.cta-btn:hover {
    background-color: #e37164;/* マウスホバー時 */
}
.cta-btn:active {
    -ms-transform: translateY(4px);
    -webkit-transform: translateY(4px);
    transform: translateY(4px);
    border-bottom: none;
}
</style>

補足:FontAwesomeの読み込み

ボタンのアイコンはFontAwesomeを使っています。FontAwesomeを読み込んでない方はフッタなどに以下を追加してください。既にどこかで使ってる方は不要です。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

以上、記事下にCTAを設置するカスタマイズでした。よろしければどうぞご利用下さい。
その他のはてなブログカスタマイズ記事はこちらをどうぞ。
blog.minimal-green.com