Skip to content

見出し要素デザインサンプル

見出し要素のデザインのサンプルです。見出しレベル(<h1><h6>)やclass名、色やフォントサイズなどは適宜変更してください。
以下サンプルをもとに、いろいろいじってみるのもたのしいと思います。

見出しサンプル1

上下に罫線の入ったオーソドックスな見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding: 1.5em 0;
  font-size: 1.25em;
  line-height: 1.6;
  border-top: 1px solid #454545;
  border-bottom: 1px solid #454545;
}

上下の線の種類や太さ、色を変えるだけでも結構なバリエーションが出ます。
このパターンのサンプルをいくつかCodePenにおいているので、こちらもご参考ください。

見出しサンプル2

上半分を違う色にしてアクセントをつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding-left: 0.75em;
  font-size: 1.25em;
  line-height: 1.6;
  border-left: 5px solid #454545;
  position: relative;
}

.headline::before {
  content: '';
  background-color: #d5393e;
  width: 5px;
  height: 50%;
  position: absolute;
  top: 0;
  left: -5px;
  display: inline-block;
}

ボーダーの色や上に乗せる色の高さ(heightを変えると少し印象が変わります。
ボーダー幅はあまり細すぎるとアンバランスな感じになるので、少し太めにするとよいです。

見出しサンプル3

左右にラインが伸びた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  margin-inline: auto;
  padding: 0 1em;
  font-size: 1.25em;
  line-height: 1.6;
  text-align: center;
  width: fit-content;
  position: relative;
}

.headline::before,
.headline::after {
  content: '';
  background-color: #454545;
  width: 3em;
  height: 1px;
  position: absolute;
  top: 50%;
  display: inline-block;
}

.headline::before {
  left: -3em;
}

.headline::after {
  right: -3em;
}

あまり長い文言向きではないかも。線の太さやパターンで少し印象が変わります。
このパターンのサンプルをいくつかCodePenにおいているので、こちらもご参考ください。

見出しサンプル4

外側にさらに縁をつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  margin-inline: 10px;
  padding: 1em;
  color: #fff;
  font-size: 1.25em;
  line-height: 1.6;
  background-color: #454545;
  border: 1px solid #fff;
  outline: 10px solid #454545;
}

白枠(border)のさらに外側に縁(outline)をつけています。
outlineで指定した太さの分だけ長さが横に延びるので、コンテンツ幅と揃えるにはmargin-inlineで左右同じ長さで指定して調整します。

見出しサンプル5

ワンポイントに斜めストライプをあしらった見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding: 1em 1em 1em 2em;
  font-size: 1.25em;
  line-height: 1.6;
  border: 2px solid #454545;
  position: relative;
}

.headline::before {
  content: '';
  background: repeating-linear-gradient(-45deg, #454545 0 2px, #fff 2px 6px);
  width: 15px;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
}

枠とストライプの色を揃えるときれいです。
CSSで作るストライプは線の指定pxが小さすぎるときれいなストライプにならないので、調整時には注意が必要です。

見出しサンプル6

ベタ塗りに下ラインでアクセントをつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding: 1em;
  color: #fff;
  font-size: 1.25em;
  line-height: 1.6;
  background-color: #454545;
  position: relative;
}

.headline::after {
  content: '';
  background-color: #454545;
  width: 100%;
  height: 2px;
  position: absolute;
  bottom: -5px;
  left: 0;
  display: inline-block;
}

見出しサンプル7

すこし動きがあり目を引く見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding: 1em;
  font-size: 1.25em;
  line-height: 1.6;
  background-color: #fff;
  border: 2px solid #454545;
  position: relative;
}

.headline::after {
  content: '';
  background-color: #454545;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-1.5deg);
  display: inline-block;
  z-index: -1;
}

transform: rotate(-1.5deg)の数値を正の数にすると、回転が逆になります。

見出しサンプル8

擬似的に背景が透けて見えるような見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  margin-right: 10px;
  padding: 1em 1em 1em 1.5em;
  font-size: 1.25em;
  line-height: 1.6;
  border: 1px solid #454545;
  position: relative;
}

.headline::after {
  content: '';
  background-color: #ebebef;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 10px;
  right: -10px;
  display: inline-block;
  z-index: -1;
}

背景色がはみ出す分、見出しの横幅はmargin-rightで同じだけ調整しています。

見出しサンプル9

2本の斜め線でアクセントをつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding-left: 1.5em;
  font-size: 1.25em;
  line-height: 1.6;
  position: relative;
}

.headline::before,
.headline::after {
  content: '';
  background-color: #454545;
  width: 2px;
  height: 100%;
  position: absolute;
  top: 0;
  transform: rotate(20deg);
  display: inline-block;
}

.headline::before {
  left: 5px;
}

.headline::after {
  left: 10px;
}

見出しサンプル10

紙のような折り目をつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding: 1em;
  color: #fff;
  font-size: 1.25em;
  line-height: 1.6;
  background-color: #454545;
  position: relative;
}

.headline::after {
  content: '';
  background-color: #454545;
  border-width: 20px 20px 0 0;
  border-style: solid;
  border-color: #d5393e #fff;
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-block;
}

折り目の部分は、折り目の色(#d5393e)と背景色(#fff)の2色を指定します。
border-widthで指定している折り目の大きさを変えてみるのも、たのしいかもしれません。

見出しサンプル11

左上にアクセントをつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  margin-inline: 8px;
  padding: 1em 1.5em;
  font-size: 1.25em;
  line-height: 1.6;
  background: linear-gradient(-45deg, #fff 30px calc(100% - 30px), transparent calc(100% - 30px)), repeating-linear-gradient(-45deg, #454545 0 2px, #fff 2px 6px);
  outline: 3px solid #454545;
  outline-offset: 5px;
}

先のストライプつき見出し同様、CSSで作るストライプは線の指定pxが小さすぎるときれいなストライプにならないので、調整時には注意が必要です。

見出しサンプル12

左側を違う色にしてアクセントをつけた見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding-bottom: 0.5em;
  font-size: 1.25em;
  line-height: 1.6;
  border-bottom: 2px solid #454545;
  position: relative;
}

.headline::before {
  content: '';
  background-color: #d5393e;
  width: 5em;
  height: 2px;
  position: absolute;
  bottom: -2px;
  left: 0;
  display: inline-block;
}

見出しサンプル13

下線ストライプ見出し

見出しサンプル

html
<h2 class="headline">見出しサンプル</h2>
css
.headline {
  padding-bottom: 1em;
  font-size: 1.25em;
  line-height: 1.6;
  position: relative;
}

.headline::before {
  content: '';
  background: repeating-linear-gradient(-45deg, #454545 0 2px, #fff 2px 6px);
  width: 100%;
  height: 10px;
  position: absolute;
  bottom: 0;
  left: 0;
  display: inline-block;
}

先のストライプつき見出し同様、CSSで作るストライプは線の指定pxが小さすぎるときれいなストライプにならないので、調整時には注意が必要です。