ブロックの上にかかったリボンデザインです。
リボンは[clip-path]を利用して作ることも可能です。
<div class="cp_card">
コンテンツ
<div class="cp_ribbon11">
<div class="cp_ribbon">Ribbon</div>
</div>
</div>
.cp_card {
position: relative;/*リボンをかけたいコンテンツボックスにセット*/
width: 300px;
height: 300px;
background: #ffffff;
margin: auto;
padding: 60px 5px 0;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
/*リボンの設定*/
.cp_ribbon11 {
line-height: 50px;
position: absolute;
top: 15px;
display: flex;
justify-content: center;
align-items: center;
width: calc(100% + 10px);
height: 40px;
margin-right: -10px;
margin-left: -10px;
text-align: center;
color: #ffffff;
background: #2196F3;
}
/*リボンの影の共通設定*/
.cp_ribbon11:before,
.cp_ribbon11:after {
position: absolute;
top: 100%;
content: '';
border-top: 5px solid #1565C0;
border-left: 5px solid transparent;
}
.cp_ribbon11:before {
left: 0;
}
.cp_ribbon11:after {
right: 0;
transform: scale(-1, 1);/*左右反転*/
}
CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。
@CopypetJp More Info