イメージ HTML
1 2 3 4 5 6 |
<div> <section> <h1>タイトル</h1> <p>テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト</p> </section> </div> |
CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
div{ padding:10px 0; background-color:#ccc; } section{ margin:0 10px; padding:50px 0 10px; background-color:#fff; position:relative; } h1{ width:90%; margin:auto; padding:10px 0; position:absolute; top:-8px; left:0; right:0; background-color:#f55; color:#fff; text-align:center; } h1::before{ position:absolute; top:0; left:-8px; width:0; height:0; content:""; border:4px solid transparent; border-bottom:4px solid #800; border-right:4px solid #800; } p{ margin:0 20px; } |
beforeの疑似要素で直角三角形を作っています。 そして、 […]