html5とCSS3による装飾サンプル
html5とCSS3のサンプルの実用的なものがたくさんあります。
その一部をランダムに表示しています。 詳しくは サンプルページへどうぞ
-
>>テキストを変形する(1) - 斜体 テキストに装飾
サンプルテキスト ABCDEFG
※ テキストに斜体をかけます。
[ 閉じる ]
htmlソース
<p class="text-ex13"> サンプルテキスト ABCDEFG </p>
CSS
.text-ex13{ transform: skewX(-15deg); /* フォントに斜体をかけます */ font-size: 30px !important; /* わかりやすいようにフォントを大きくします */ font-weight: normal; color: #333; padding: 1rem; }
-
>>背景の採色・模様 (1) - 市松 赤黒柄 背景の装飾
背景の採色・模様
※ 市松模様の背景パターンです。
[ 閉じる ]
htmlソース
<p class="background-ex1"> <span>背景の採色・模様</span> </p>
CSS
.background-ex1 { background-color: red; background-image: linear-gradient(45deg, #333 25%, transparent 0), linear-gradient(45deg, transparent 75%, #333 0), linear-gradient(45deg, #333 25%, transparent 0), linear-gradient(45deg, transparent 75%, #333 0); background-size: 30px 30px; background-position: 0 0, 15px 15px, 15px 15px, 30px 30px; /* ここまでが背景の柄を描く部分 */ color: #fff; font-size: 20px !important; font-weight: bold; height: 56px; width: 100%; padding: 0 !important; display: flex; align-items: center; } .background-ex1 span{ padding-left: 10px; }
-
>>タイトルにアイコンをつける (border-4) アイコンで装飾
タイトルにアイコンをつける
※ CSSでボーダーを変形させてアイコンを作成しています。
borderの角の描画特性を利用したアイコンです。 画像を用意しなくて良いので便利ではあります。[ 閉じる ]
htmlソース
<h4 class="icon-ex11"> タイトルにアイコンをつける </h4>
CSS
.icon-ex11{ position: relative; font-size: 20px; font-weight: normal; position: relative; padding-left: 20px !important; display: flex; align-items: center; height: 36px; } .icon-ex11::before { position: absolute; content: ''; box-sizing: border-box; left: 0; width: 6px; height: 10px; background: pink; } .icon-ex11::after { position: absolute; content: ''; box-sizing: border-box; left: 6px; border: 10px solid transparent; border-left: 10px solid pink; margin-right: 10px; }