コピペでできる!cssとhtmlのみで作るSVGを使用した斜め切り替えヘッダー6種

CSS HTML
 2018.03.27

ブログやランディングページでよく見かける切り替え部分を斜めにしたヘッダーです。
コンテンツとコンテンツの切り替えで使用するとシュッとした感じのサイトになりますね。
毎度毎度SVGを用意して作るのが面倒なので、良く使いそうなパターンをご用意しました。
こちらは直接SVGを指定するバージョンです。
レスポンシブにも対応していますが、好みに合わせて微調整した方がいいかもしれません。

browser:  65 11 20 10 

SVGを使用した斜め切り替えヘッダー[6種]

右斜め上にカットされたヘッダー

ニャン易度

Header

Content

<header>
<h1>Header</h1>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,100 100,0 100,100"/>
</svg>
</header>
<article>
<section>
<h2>Content</h2>
</section>
</article>
header {
	position: relative;
	height: 200px;
	background: #00bcd4;
}
svg {
	position: absolute;
	bottom: 0;
	width: 100%;
	height: 100px;
	fill: #80deea;
}
section {
	background: #80deea;
}
h1,h2 {
	margin: 0;
	padding: 1em 0;
	text-align: center;
	color: #ffffff;
}

左斜め上にカットされたヘッダー

ニャン易度

Header

Content

<header>
<h1>Header</h1>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,0 100,100 0,100"/>
</svg>
</header>
<article>
<section>
<h2>Content</h2>
</section>
</article>
header {
	position: relative;
	height: 200px;
	background: #00bcd4;
}
svg {
	position: absolute;
	bottom: 0;
	width: 100%;
	height: 100px;
	fill: #80deea;
}
section {
	background: #80deea;
}
h1,h2 {
	font-size: 2em;
	margin: 0;
	padding: 1em 0;
	text-align: center;
	color: #ffffff;
}

Vの字にカットされたヘッダー

ニャン易度

Header

Content

<header>
<h1>Header</h1>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="0,0 50,50 100,0"/>
</svg>
</header>
<article>
<section>
<h2>Content</h2>
</section>
</article>
header {
	position: relative;
	height: 100px;
	background: #00bcd4;
}
svg {
	position: absolute;
	bottom: -100px;
	width: 100%;
	height: 100px;
	fill: #00bcd4;
}
section {
	height: 200px;
	background: #80deea;
}
h1,h2 {
	font-size: 2em;
	margin: 0;
	padding: 1em 0;
	text-align: center;
	color: #ffffff;
}
h2 {
	padding: 3em 0 1em;
}

逆Vの字にカットされたヘッダー

ニャン易度

Header

Content

<header>
<h1>Header</h1>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="100,100 50,50 0,100"/>
</svg>
</header>
<article>
<section>
<h2>Content</h2>
</section>
</article>
header {
	position: relative;
	height: 200px;
	background: #00bcd4;
}
svg {
	position: absolute;
	bottom: 0;
	width: 100%;
	height: 100px;
	fill: #80deea;
}
section {
	background: #80deea;
}
h1,h2 {
	font-size: 2em;
	margin: 0;
	padding: 1em 0;
	text-align: center;
	color: #ffffff;
}

下向きでラウンドにカットされたヘッダー

ニャン易度

Header

Content

<header>
<h1>Header</h1>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<path d="M0,0 Q50,50 100,0"></path>
</svg>
</header>
<article>
<section>
<h2>Content</h2>
</section>
</article>
header {
	position: relative;
	height: 150px;
	background: #00bcd4;
}
svg {
	position: absolute;
	bottom: -100px;
	width: 100%;
	height: 100px;
	fill: #00bcd4;
}
section {
	height: 150px;
	background: #80deea;
}
h1,h2 {
	font-size: 2em;
	margin: 0;
	padding: 1em 0;
	text-align: center;
	color: #ffffff;
}
h2 {
	padding: 2em 0 1em;
}

上向きでラウンドにカットされたヘッダー

ニャン易度

Header

Content

<header>
<h1>Header</h1>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<path d="M0,50 Q50,0 100,50"></path>
</svg>
</header>
<article>
<section>
<h2>Content</h2>
</section>
</article>
header {
	position: relative;
	height: 150px;
	background: #00bcd4;
	background-size: cover;
}
svg {
	position: absolute;
	bottom: -50px;
	width: 100%;
	height: 100px;
	fill: #80deea;
}
section {
	height: 150px;
	background: #80deea;
}
h1,h2 {
	font-size: 2em;
	margin: 0;
	padding: 1em 0;
	text-align: center;
	color: #ffffff;
}

copypet.jp

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

More Info

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