リボン風の見出しです。
clip-pathは使えるようになると、いろんな形が作れるようになるので、便利です。
最近はジェネレータもあるので、使ってみてください。
CSS Clip Path Generator Online | 10015 Tools
Online CSS Clip Path Generator is a free tool for generating CSS clip path. You can mask your images with CSS clip-path property by previewing the path online.……
<h1 class="cp_h1title"><span>見出しテキスト</span></h1>
.cp_h1title {
position: relative;
color: #f8f8f8;
background: #fa7d7a;
text-align: center;
width: fit-content;
margin: auto;
padding: 0px 10px;
box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.3),
0 0px 0px 0px rgba(0, 0, 0, 0.7)inset;
}
.cp_h1title::before,
.cp_h1title::after {/*外側のリボン*/
position: absolute;
content: '';
bottom: -6px;
background: #fa7d7a;
width: 40px;
height: 40px;
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 30% 50%);
z-index: -2;
}
.cp_h1title::before {
left: -32px;
transform: rotate(-4deg);
}
.cp_h1title::after {
right: -32px;
transform: rotate(4deg) scale(-1, 1);/*角度をつけて左右反転*/
}
.cp_h1title span::before,
.cp_h1title span::after {/*リボンの折り返しの影*/
position: absolute;
content: '';
top: 100%;
background: #f0470c;
width: 10px;
height: 5px;
clip-path: polygon(0% 0%, 100% 0%, 100% 100%);
z-index: -1;
}
.cp_h1title span::before {
left: 0;
}
.cp_h1title span::after {
right: 0;
transform: scale(-1, 1);/*左右反転*/
}
CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。
@CopypetJp More Info