ひと昔前は、画像でしか表現できなかったようなデザイン性のある見出しも、今ではそのほとんどがCSSだけで表現できます。
ご紹介のスタイルは原則、テキストの折り返しには対応させていません。また、Wordpressテーマ固有のCSSスタイルが影響しているため、プレビューでの見た目とご紹介のCSSコードでは、余白や要素の位置などに若干の違いがありますので、コードをそのまま利用される場合は調整の必要があります。
シンプルな見出し
ぼかし無しシャドウの見出し
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
color: #FFF;
font-size: 18px;
font-weight: bold;
background-color: #1874E1;
box-shadow: 4px 4px 0 #125EB6;
padding: 1rem 2rem;
}
ボーダーの色違い
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
border-bottom: 5px solid #4993EB;
font-size: 18px;
font-weight: bold;
padding: 1rem;
position: relative;
}
h1::before {
position: absolute;
bottom: -5px;
left: 0;
width: 20%;
height: 5px;
content: '';
background: #125EB6;
}
テキスト左右にボーダー
プレビューサンプル
<h1><span>見出しタイトル</span></h1>
h1 {
font-size: 18px;
font-weight: bold;
text-align: center;
}
h1::before {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%;
height: 2px;
content: "";
background-color: #999;
}
h1 span {
background-color: #FFF;
padding: 0 40px;
position: relative;
}
テキストに背景色をつけ、paddingで左右の余白を調整してるので、テキスト数によるボーダー幅を気にする必要がありません。h1::beforeのwidthを100%にすれば、親要素一杯にボーダーが広がります。
ただし、ご紹介のやり方ではテキストが折り返される場合は表示が崩れますので、もう少し調整が必要です。
短い下ボーダー
プレビューサンプル
<h1>お問い合わせ<span>CONTACT</span></h1>
h1 {
font-size: 18px;
font-weight: bold;
text-align: center;
position: relative;
}
h1::before {
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 3px;
content: "";
background-color: #1874E1;
}
h1 span {
font-size: 11px;
display: block;
margin-top: 5px;
}
グラデーションを使った見出し
シンプルな見出し
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
color: #FFF;
font-size: 18px;
font-weight: bold;
padding: 1em;
background: linear-gradient(90deg, rgba(28,144,224,1) 0%, rgba(118,193,245,1) 100%);
}
上記コードにborder-radiusを追加すれば角丸デザインになります。
平行四辺形な見出し
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
color: #FFF;
font-size: 18px;
font-weight: bold;
padding: 1em;
background: linear-gradient(90deg, rgba(28,144,224,1) 0%, rgba(118,193,245,1) 100%);
transform: skew(-15deg);
}
上記コードにborder-radiusを追加すれば角丸デザインになります。
下ボーダーの見出し
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
font-weight: bold;
padding: 1em;
position: relative;
}
h1::after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 4px;
content: "";
background: linear-gradient(90deg, rgba(28,144,224,1) 0%, rgba(118,193,245,1) 100%);
}
上記コードにborder-radiusを追加すれば角丸デザインになります。
タグ・リボン風の見出し
タグ風の見出し
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
font-weight: bold;
padding: 21px;
position: relative;
display: inline-block;
color: #fff;
background-color: #1874E1;
margin-left: 30px;
height: 60px;
}
h1::before {
position: absolute;
top: 0;
left: -30px;
content: "";
border-width: 30px 30px 30px 0;
border-style: solid;
border-color: transparent #1874E1 transparent transparent;
}
h1::after {
position: absolute;
top: 50%;
left: -10px;
transform: translateY(-50%);
width: 12px;
height: 12px;
border-radius: 50%;
background-color: #FFF;
content: "";
}
::beforeで左の三角部分を作り、::afterで白い丸を表現しています。
リボン風の見出し1
プレビューサンプル
<h1><span>見出しタイトル</span></h1>
h1 {
display: inline-block;
text-align: center;
position: relative;
height: 45px;
}
h1::before {
content: "";
position: absolute;
bottom: -10px;
left: -35px;
z-index: -2;
border: 20px solid #428FEA;
border-left-color: transparent;
width: 10px;
}
h1::after {
content: "";
position: absolute;
bottom: -10px;
right: -35px;
z-index: -2;
border: 20px solid #428FEA;
border-right-color: transparent;
width: 10px;
}
h1 span {
display: inline-block;
position: relative;
margin: 0;
padding: 0 20px;
line-height: 45px;
background-color: #1874E1;
color: #FFF;
font-size: 18px;
font-weight: bold;
}
h1 span::before {
content: "";
position: absolute;
top: 100%;
left: 0;
border: none;
border-bottom: 10px solid transparent;
border-right: 15px solid #1257A9;
}
h1 span::after {
content: "";
position: absolute;
top: 100%;
right: 0;
border: none;
border-bottom: 10px solid transparent;
border-left: 15px solid #1257A9;
}
リボン風の見出し2
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
display: inline-block;
text-align: center;
position: relative;
height: 50px;
padding: 0 30px;
font-size: 18px;
background: #f57a78;
color: #FFF;
}
h1::before, h1::after {
content: "";
position: absolute;
z-index: 1;
width: 0;
height: 0;
}
h1::before {
top: 0;
left: 0;
border-width: 25px 0 25px 15px;
border-color: transparent transparent transparent #FFF;
border-style: solid;
}
h1::after {
top: 0;
right: 0;
border-width: 25px 15px 25px 0;
border-color: transparent #FFF transparent transparent;
border-style: solid;
}
リボン風の見出し3
プレビューサンプル
<h1><span>見出しタイトル</span></h1>
h1 {
display: inline-block;
text-align: center;
position: relative;
height: 60px;
padding: 9px 0;
font-size: 18px;
background: #f57a78;
color: #FFF;
}
h1 span {
line-height: 42px;
margin: 0;
padding: 9px 30px;
border-top: dashed 2px rgba(255, 255, 255, 0.5);
border-bottom: dashed 2px rgba(255, 255, 255, 0.5);
}
h1::before, h1::after {
content: "";
position: absolute;
z-index: 1;
width: 0;
height: 0;
}
h1::before {
top: 0;
left: 0;
border-width: 30px 0 30px 15px;
border-color: transparent transparent transparent #FFF;
border-style: solid;
}
h1::after {
top: 0;
right: 0;
border-width: 30px 15px 30px 0;
border-color: transparent #FFF transparent transparent;
border-style: solid;
}
リボン風の見出し4
プレビューサンプル
テキストテキスト
<h1><span>見出しタイトル</span></h1>
h1 {
display: inline-block;
text-align: center;
position: relative;
height: 60px;
padding: 9px 0;
font-size: 18px;
background: #f57a78;
color: #FFF;
}
h1 span {
line-height: 42px;
margin: 0;
padding: 9px 30px;
border-top: dashed 2px rgba(255, 255, 255, 0.5);
border-bottom: dashed 2px rgba(255, 255, 255, 0.5);
}
h1::before, h1::after {
content: "";
position: absolute;
z-index: 1;
width: 0;
height: 0;
}
h1::before {
top: 0;
left: 0;
border-width: 30px 0 30px 15px;
border-color: transparent transparent transparent #FFF;
border-style: solid;
}
h1::after {
top: 0;
right: 0;
border-width: 30px 15px 30px 0;
border-color: transparent #FFF transparent transparent;
border-style: solid;
}
リボン風の見出し5
プレビューサンプル
<h1><span><i class="fas fa-star"></i></span>見出しタイトル</h1>
h1 {
position: relative;
background: #FFF;
font-size: 18px;
padding: 25px 15px 25px 90px;
}
h1 span {
display: inline-block;
position: absolute;
top: -6px;
left: 20px;
margin: 0;
padding: 15px 0;
z-index: 2;
width: 50px;
text-align: center;
color: #FFF;
font-size: 18px;
background-color: #1874E1;
}
h1 span::before {
position: absolute;
content:"";
top: 0;
right: -6px;
border-bottom: 6px solid #10509B;
border-right: 6px solid transparent;
}
h1 span::after {
position: absolute;
content:"";
top: 100%;
left: 0;
width: 0;
height: 0;
border-bottom: 10px solid transparent;
border-left: 25px solid #1874E1;
border-right: 25px solid #1874E1;
}
サンプルでは<span>~</span>にFont Awesomeのアイコンを表示していますが、テキストでもOKです。
リボン風の見出し6
プレビューサンプル
<h1><span><i class="fas fa-star"></i></span>見出しタイトル</h1>
h1 {
position: relative;
background: #FFF;
font-size: 18px;
padding: 25px;
}
h1 span {
display: inline-block;
position: absolute;
top: -6px;
left: 20px;
margin: 0;
padding: 15px 0;
z-index: 2;
width: 50px;
text-align: center;
color: #FFF;
font-size: 18px;
background-color: #1874E1;
}
h1 span::before {
position: absolute;
content:"";
top: 0;
right: -6px;
border-bottom: 6px solid #10509B;
border-right: 6px solid transparent;
}
h1 span::after {
position: absolute;
content:"";
top: 100%;
left: 0;
width: 0;
height: 0;
border-bottom: 10px solid transparent;
border-left: 25px solid #1874E1;
border-right: 25px solid #1874E1;
}
吹き出し風見出し
吹き出し見出し1
プレビューサンプル
<h1><span><i class="fas fa-star"></i></span>見出しタイトル</h1>
h1 {
position: relative;
color: #FFF;
font-size: 18px;
padding: 25px;
border-radius: 8px;
background-color: #1874E1;
text-align: left;
}
h1::after {
position: absolute;
content:"";
bottom: -9px;
left: 30px;
width: 0;
height: 0;
border-width: 10px 10px 0 10px;
border-style: solid;
border-color: #1874E1 transparent transparent transparent;
}
吹き出し見出し2
プレビューサンプル
<h1><span><i class="fas fa-star"></i></span>見出しタイトル</h1>
h1 {
position: relative;
color: #FFF;
font-size: 18px;
padding: 25px;
border-radius: 8px;
background-color: #1874E1;
text-align: left;
}
h1::after {
position: absolute;
content:"";
bottom: -9px;
left: 30px;
width: 0;
height: 0;
border-width: 10px 10px 0 10px;
border-style: solid;
border-color: #1874E1 transparent transparent transparent;
}
背景に柄がある見出し
背景柄見出し1
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
padding: 25px;
background-color: #EA3A87;
background-image: radial-gradient(#ED5A9A 13%, transparent 13%), radial-gradient(#ED5A9A 13%, transparent 13%);
background-size: 50px 50px;
background-position: 0 0, 25px 25px;
text-align: left;
color: #FFF;
}
背景柄見出し2
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
padding: 25px;
background-image: linear-gradient(-45deg, #f5eeed 25%, #f4e2de 25%, #f4e2de 50%, #f5eeed 50%, #f5eeed 75%, #f4e2de 75%, #f4e2de);
background-size: 25px 25px;
text-align: left;
position: relative;
}
background-sizeを変更すれば、ストライプの太さを変更できます。
テキストを装飾した見出し
テキスト装飾見出し1
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
font-weight: bold;
text-shadow: #fff 2px 0, #fff -2px 0, #fff 0 -2px, #fff 0 2px, #fff 2px 2px, #fff -2px 2px, #fff 2px -2px, #fff -2px -2px, #fff 1px 2px, #fff -1px 2px, #fff 1px -2px, #fff -1px -2px, #fff 2px 1px, #fff -2px 1px, #fff 2px -1px, #fff -2px -1px;
}
数値を大きくすると縁取りが太くなりますが、大きくしすぎるとギザギザが目立ってきます。
テキスト装飾見出し2
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
font-weight: bold;
text-shadow: #fff 2px 0, #fff -2px 0, #fff 0 -2px, #fff 0 2px, #fff 2px 2px, #fff -2px 2px, #fff 2px -2px, #fff -2px -2px, #fff 1px 2px, #fff -1px 2px, #fff 1px -2px, #fff -1px -2px, #fff 2px 1px, #fff -2px 1px, #fff 2px -1px, #fff -2px -1px;
}
text-shadowは複数指定できるので、縁取り用とドロップシャドウ用の2つを指定します。
テキスト装飾見出し3
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
font-weight: bold;
padding: 25px;
position: relative;
border: 2px solid #333;
text-align: left;
}
h1::before {
font-size: 13px;
font-weight: normal;
position: absolute;
top: -26px;
left: -2px;
line-height: 24px;
padding: 0 25px;
content: 'POINT';
color: #FFF;
background-color: #333;
letter-spacing: 2px;
}
H要素よりdivなどの方が使い道の多いスタイルだと思います。
テキスト装飾見出し4
プレビューサンプル
<h1>見出しタイトル</h1>
h1 {
font-size: 18px;
font-weight: bold;
padding: 25px;
position: relative;
border: 2px solid #333;
text-align: left;
}
h1::before {
font-size: 13px;
font-weight: 900;
font-family: "Font Awesome 5 Free";
position: absolute;
top: -26px;
left: -2px;
line-height: 24px;
padding: 0 25px;
content: '\f0a4 POINT';
color: #FFF;
background-color: #333;
letter-spacing: 2px;
}
Font Awesomeのアイコンを表示したパターン。こちらもdivなどの方が使い道の多いスタイルだと思います。
おまけ
タイトルの装飾ではないですが、ボックス角にかかるリボンの様なスタイルです。
ボックスの角にリボン1
プレビューサンプル
<div class="box"> <p><span>NEW</span></p> </div>
.box {
padding: 25px;
position: relative;
text-align: left;
background-color: #DDD;
width: 300px;
height: 150px;
margin: 0 auto;
}
.box p {
position: absolute;
top: -6px;
right: -6px;
width: 89px;
height: 91px;
overflow: hidden;
}
.box p span {
display: inline-block;
position: absolute;
padding: 7px 0;
top: 22px;
left: -23px;
width: 160px;
text-align: center;
font-size: 12px;
font-weight: bold;
line-height: 16px;
background: #1874E1;
color: #FFF;
letter-spacing: 0.05em;
transform: rotate(45deg);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.box p span::before, .box p span::after {
position: absolute;
bottom: -4px;
content: "";
border-top: 4px solid #1462BF;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
}
.box p span::before {
left: 14px;
}
.box p span::after {
right: 18px;
}
ボックスの角にリボン2
プレビューサンプル
<div class="box"> <p><span>NEW</span></p> </div>
.box {
padding: 25px;
position: relative;
text-align: left;
background-color: #DDD;
width: 300px;
height: 150px;
margin: 0 auto;
}
.box p {
position: absolute;
top: 0;
right: 0;
width: 85px;
height: 85px;
overflow: hidden;
}
.box p span {
display: inline-block;
position: absolute;
padding: 5px 0;
top: 20px;
left: -24px;
width: 160px;
text-align: center;
font-size: 12px;
font-weight: bold;
line-height: 16px;
background: #1874E1;
color: #FFF;
letter-spacing: 0.05em;
transform: rotate(45deg);
box-shadow: 0 0 0 2px rgb(24, 116, 225);
border-top: dashed 1px rgba(255, 255, 255, 0.65);
border-bottom: dashed 1px rgba(255, 255, 255, 0.65);
}
この記事を書いた人管理人
SAKURAGRAPHICA代表
会社員の傍ら、フリーランスでWEBサイトの制作やWordPressによるCMSの構築・障がい者の就労支援としてホームページ制作の職業指導員も行っております。










