html5とCSS3による装飾サンプル
html5とCSS3のサンプルの実用的なものがたくさんあります。
その一部をランダムに表示しています。 詳しくは サンプルページへどうぞ
-
>>見出しを下線で装飾する(1) 見出しの装飾
見出しを下線で装飾する 方法その(1)
※ タイトル(テキスト)の下線をposition → absoluteを利用して相対的な位置指定で 装飾する。
[ 閉じる ]
htmlソース
<h4 class="title-ex1"> 見出しを下線で装飾する 方法その(1) </h4>
CSS
.title-ex1{ position: relative; padding: 0.3em 0.3em 0.5em 0 !important; /* 本システムCSSの干渉を変更します */ color: #333; height: 32px; font-size: 20px !important; font-weight: normal; display: flex; align-items: center; } .title-ex1::after { position: absolute; bottom: 2px; left: 0; z-index: -1; content: ''; width: 100%; height: 16px; background: linear-gradient(45deg, green 50%, white 100%); }
-
>>タイトルにSVGでアイコンをつける(2) アイコンで装飾
タイトルにアイコンをつける(SVG-2)
※ タイトルにSVGでアイコンをつける。 このSVGはMITライセンスでの利用となります。
The MIT License (MIT) Copyright © 2019-2020 css.gg[ 閉じる ]
htmlソース
<h4 class="icon-ex4"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M12.0519 14.8285L13.4661 16.2427L17.7087 12L13.4661 7.7574L12.0519 9.17161L13.8803 11H6.34318V13H13.8803L12.0519 14.8285Z" fill="currentColor" /><path fill-rule="evenodd" clip-rule="evenodd" d="M1 19C1 21.2091 2.79086 23 5 23H19C21.2091 23 23 21.2091 23 19V5C23 2.79086 21.2091 1 19 1H5C2.79086 1 1 2.79086 1 5V19ZM5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21Z" fill="currentColor" /> </svg> タイトルにアイコンをつける(SVG-2) </h4>
CSS
.icon-ex4{ font-size: 20px; font-weight: normal; color: #333; padding: 1rem; display: flex; align-items: center; height: 36px; } .icon-ex4 svg { width: 24px; margin-right: 8px; margin-bottom: 4px; }
-
>>テキストに影をつける(5) テキストに装飾
サンプルテキスト ABCDEFG
※ テキストに影をつけて縁取りのようにすることができます。
文字間をすこし広げてみました。[ 閉じる ]
htmlソース
<p class="text-ex5"> サンプルテキスト ABCDEFG </p>
CSS
.text-ex5{ font-size: 2.2em !important; /* 強制的にフォントを大きくします */ font-weight:bold; letter-spacing: 4px; /* 文字間隔をあけます */ color: white; text-shadow: 2px 2px 1px #666, -2px 2px 1px #666, 2px -2px 1px #666, -2px -2px 1px #666, 2px 0px 1px #666, 0px 2px 1px #666, -2px 0px 1px #666, 0px -2px 1px #666; }