コピペでできる!CSSとhtmlだけの中央寄せのテキストと相性のいい見出しデザイン15選

CSS HTML
 2018.01.06
 2018.03.12

htmlとcssだけでできる見出し15選です。
見出し次第で、記事の読みやすさは大きく変わります。
テキストをセンターに寄せた時に相性の良い見出しを集めました。

色は好みで変えていただければ、かまいません。
また、基本htmlは<h1>タグを使用していますが、<h2>〜<h6>などにそのまま変更することができます。

紹介している<h1>タグには、クラス名(.cp_h1title)を付与していますが、こちらも
css部分を下記のように変更すれば、クラスをつけずに使用することも可能です。

h1 {cssの中身}

色には6桁の16進数のカラーコード(#000000)も使えますが、他に、

  • 3桁の16進数カラーコード(#000)
  • RGB色相・彩度・明度(rgb(0,0,0))
  • RGBA色相・彩度・明度・透明度(rgb(0,0,0,1))

なども使用できます。
RGBA値での指定は、サポートしていないブラウザだと、透明度だけが無視されるのではなく、色指定そのものが認識されずに無効となるので注意が必要です。

browser:  65 11 20 10 

中央寄せテキストと相性のよい見出し [15種]

中央寄せのテキストと相性のよい見出しを集めました。

全体を囲む時は「border: サイズ 種類 色;」のようにボーダーの位置を省略できます
角丸は「border-radius:サイズ;」で指定します。
サイズは「左上、右上、右下、左下」の順番です。全て同じ場合は省略して1つだけの記載でOKです。
また、iOS8以下やAndroid4.4.4以下対応が必要な時は「-webkit-border-radius: サイズ;」にてベンダープレフィックスの指定を追加します。指定はこちら。

上下で太さを変える

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	padding: .3em;
	border-top: 1px solid #E91E63;
	border-bottom: 3px solid #E91E63;
	text-align: center;
	color:#C2185B;
}

上下に二重のライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	padding: 4px 0;
	border-top: 3px double #2196F3;
	border-bottom: 3px double #2196F3;
	text-align: center;
	color: #1565C0;
}

上下に二重のライン(太さをそれぞれ変える)

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	padding: .3em;
	text-align: center;
	color:#EF6C00;
}
.cp_h1title::before,
.cp_h1title::after {
	position: absolute;
	left: 0;
	content: '';
	width: 100%;
	height: 6px;
	box-sizing: border-box;
}
.cp_h1title::before {
	top: 0;
	border-top: 2px solid #F57C00;
	border-bottom: 1px solid #F57C00;
}
.cp_h1title::after {
	bottom: 0;
	border-top: 1px solid #F57C00;
	border-bottom: 2px solid #F57C00;
}

両端に横ライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	display: inline-block;
	width: 100%;
	padding: 0 17%;
	text-align: center;
	color:#00acc1;
}
.cp_h1title::before,
.cp_h1title::after {
	content: '';
	position: absolute;
	top: 50%;
	display: inline-block;
	width: 15%;
	height: 3px;
	border-top: 3px solid #00acc1;
}
.cp_h1title::before {
	left:0;
}
.cp_h1title::after {
	right: 0;
}

両端に消える横ライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	display: inline-block;
	padding: 0 17%;
	text-align: center;
	color:#F4511E;
}
.cp_h1title:before, .cp_h1title:after {
	content: '';
	position: absolute;
	top: 50%;
	display: inline-block;
	width: 15%;
	height: 1px;
	background-color: #F4511E;
}
.cp_h1title:before {
	left:0;
	background: linear-gradient(-45deg, transparent, #F4511E 10%, #F4511E 30%, transparent);
}
.cp_h1title:after {
	right: 0;
	background: linear-gradient(-45deg, transparent, #F4511E 70%, #F4511E 90%, transparent);
}

両端に二重のライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	display: inline-block;
	padding: 0 17%;
	text-align: center;
	color:#01579B;
}
.cp_h1title:before, .cp_h1title:after {
	content: '';
	position: absolute;
	top: 50%;
	display: inline-block;
	width: 15%;
	height: 3px;
	border-top: 3px double #03A9F4;
}
.cp_h1title:before {
	left:0;
}
.cp_h1title:after {
	right: 0;
}

文字下に短めのライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	margin-bottom: 1em;
	text-align: center;
}
.cp_h1title:before {
	content: '';
	position: absolute;
	bottom: -15px;
	display: inline-block;
	width: 10%;
	height: 5px;
	left: 50%;
	transform: translateX(-50%);
	background-color: #F06292;
	border-radius: 2px;
}

両端にスラッシュのライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	padding: 0 45px;
	text-align: center;
}
.cp_h1title:before, .cp_h1title:after {
	content: '';
	position: absolute;
	top: 50%;
	display: inline-block;
	width: 44px;
	height: 2px;
	background-color: #00897B;
	transform: rotate(-60deg);
}
.cp_h1title:before {
	left:0;
}
.cp_h1title:after {
	right: 0;
}

上下に丸括弧

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	padding: .3em;
	text-align: center;
}
.cp_h1title:before {
	content: "";
	position: absolute;
	top: -20%;
	left: 50%;
	width: 150px;
	height: 130%;
	border-radius: 50%;
	border: 5px solid #F48FB1;
	border-left-color: transparent;
	border-right-color: transparent;
	transform: translateX(-50%);
}

両端にカギカッコ

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	padding: .3em;
	text-align: center;
}
.cp_h1title:before,.cp_h1title:after {
	content:'';
	width: 20px;
	height: 30px;
	position: absolute;
	display: inline-block;
}
.cp_h1title:before {
	border-left: solid 2px #283593;
	border-top: solid 2px #283593;
	top:0;
	left: 0;
}
.cp_h1title:after {
	border-right: solid 2px #283593;
	border-bottom: solid 2px #283593;
	bottom:0;
	right: 0;
}

両端に大カッコ

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	padding: .3em;
	text-align: center;
}
.cp_h1title:before,.cp_h1title:after { 
	position: absolute;
	top: 0;
	content:'';
	width: 8px;
	height: 100%;
	display: inline-block;
	border-top: solid 2px #FF7043;
	border-bottom: solid 2px #FF7043;
}
.cp_h1title:before {
	border-left: solid 2px #FF7043;
	left: 0;
}
.cp_h1title:after {
	border-right: solid 2px #FF7043;
	right: 0;
}

背景を斜めに

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	position: relative;
	padding: .3em;
	text-align: center;
	background: #FFEE58;
	transform: rotate(-1deg) skew(-1deg);
	box-shadow: 0 0px 0px 0 rgba(0,0,0,0.2), 0.7em 0 0 0 #FFEE58, -0.7em 0 0 0 #FFEE58;
}

両端に三角カッコ

ニャン易度

見出しテキスト

<h1 class="cp_h1title"><span>見出しテキスト</span></h1>
.cp_h1title {
	position: relative;
	overflow: hidden;
	height: 36px;
	padding: 0;
	text-align: center;
}
.cp_h1title:before,
.cp_h1title:after {
	position: absolute;
	display: block;
	width: 20px;
	height: 36px;
	content: '';
	border: 1px solid #00897b;
}
.cp_h1title:after {
	top: 0;
	right: 2px;
}
.cp_h1title span:before,
.cp_h1title span:after {
	position: absolute;
	display: block;
	width: 30px;
	height: 55px;
	content: '';
	transform: rotate(-30deg);
	background: #fafcfc;
}
.cp_h1title span:before {
	top: -15px;
	left: 9px;
	border-left: 1px solid #00897b;
}
.cp_h1title span:after {
	z-index: 2;
	top: 0;
	right: 9px;
	border-right: 1px solid #00897b;
}

背景を塗り潰して両端にスラッシュライン

ニャン易度

見出しテキスト

<h1 class="cp_h1title">見出しテキスト</h1>
.cp_h1title {
	display: flex;
	overflow: hidden;
	background: #AB47BC;
	padding: .3em;
	align-items: center;
	color:#ffffff;
}
.cp_h1title:before,.cp_h1title:after {
	content: "";
	flex: 1;
	background: #fff;
	padding: 1px 0;
	height: 0;
	transform: rotate(45deg);
}

上部にサブテキスト

ニャン易度
サブテキスト

見出しテキスト

<div class="cp_h1title"><span>サブテキスト</span><h1>見出しテキスト</h1></div>
.cp_h1title {
	margin-top: 1em;
	padding: 5px;
	text-align: center;
	border: 1px solid #29B6F6;
}
.cp_h1title h1 {
	margin: 10px 0
}
.cp_h1title span {
	transform: translate(0, -50%);
	overflow: hidden;
	position: absolute;
	font-size: 0.8em;
	left: 0%;
	right: 0%;
	width: 35%;
	top: 44px;
	margin: 0 auto;
	background: #fafcfc;
}
.cp_h1title span:before,.cp_h1title span:after {
	content: "";
	position: absolute;
	width: 35%;
	top: 50%;
}
.cp_h1title span:before {
	transform: translate(-100%, 0);
	margin-left: -30px;
}
.cp_h1title span:after {
	margin-left: 30px;
}

copypet.jp

CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。

More Info

こんな記事はいかがですか?