・アンダーラインの削除方法
・文字デザインの色々
・下線部の装飾方法色々
・HTML記述で必要になりそうなサンプルコード集
まずは、よく見る記述方法を確認しておきましょう。
リンク先の記述方法は以下が基準となります。
- <a href="../index.html">トップページ></a>
↑の内容は単純に指定したファイルをクリップすると遷移するというものです。
ですが、これだと下線にリンク表示の意味の線が表示されてしまいます。
今回は、これを消して見栄えを良くしたいです。
ちなみに、../などの絶対パスでなくても画面遷移など指定することも可能です。
こちらの方が、階層の修正などが簡単で便利です
相対パス・絶対パスなどは調べて理解しておきましょう。
では、ここからが本題です。
アンダーラインの表示を消すためには、以下のコードを追記する必要があります。
- <a href="../index.html"style="text-decoration:none;">トップ<a>
アンダーラインの表示を消すためには、以下のコードを追記する必要があります。
- <a href="../index.html"style="text-decoration:none;">トップ<a>
はい!
これで簡単にアンダーライン表示が消えました。
「text-decoration:none」の意味は、下線を消すという意味です。
細かい記述方法は、覚えなくてもよいと思います。
重要なことはやりたいことが目的通り作れることです。
細かい部分はどんどん忘れても調べればよいので、自身のサイト開発の内容と即しているか、
目的通り動作するかを考えながら作っていきましょう。
これだけでも、十分見栄えはよいのですが、背景色と馴染みやすいように色も変更することが出来ます。
- <a href="../index.html"style="text-decoration:none;"><c style="color:#556b2f;">トップ</c></a>
これで、色も変更することができました。
「c」などの別名はなんでもいいです。分かりやすい名前がいいと思います。
たった2ステップだけで見栄えやアクセスのしやすさが全然違いますので、
自作サイトを作っている人は細かい部分も気にするようにしましょう。
次は、文字の装飾についてです。
内容は決まったけど、どんなデザインにすればいいか迷ってしまう方も多いですね。
私も背景色とよくなじむためにどんな色にしていったらよいか悩む部分です。
サンプルのソースコード共に例をまとめたので使ってみてください。
①文字の装飾
HTML
- <div class="sample2"><h2>H2 見出しタイトル</h2></div>
- <div class="sample2"><h3>H3 見出しタイトル</h3></div>
- <div class="sample2"><h4>H4 見出しタイトル</h4></div>
CSS
- html body .sample2 h2, html body .sample2 h2::before, html body .sample2 h2::after,html body .sample2 h3, html body .sample2 h3::before, html body .sample2 h3::after,html body .sample2 h4, html body .sample2 h4::before, html body .sample2 h4::after {
- all: initial !important;
- content: '' !important;
- }
- html body .sample2 h2 {
- font-size: 22px !important;
- background-color: #ff937a !important;
- font-weight: bold !important;
- color: #fff !important;
- padding: 0.5em 1em calc(0.5em - 6px) !important;
- padding-top: 10px !important;
- padding-bottom: 10px !important;
- position: relative !important;
- display: block !important;
- margin-bottom: 2em !important;
- }
- html body .sample2 h2::after {
- content: '' !important;
- background-color: #ff937a !important;
- width: 100% !important;
- height: 3px !important;
- position: absolute !important;
- bottom: -6px !important;
- left: 0 !important;
- }
- html body .sample2 h3 {
- overflow: hidden!important;
- display: block !important;
- font-family: sans-serif !important;
- font-size: 22px !important;
- font-weight: bold !important;
- margin-bottom: 2em !important;
- border-left: 7px solid #ff937a !important;
- padding: 0.5em 1em calc(0.5em - 6px) !important;
- padding-top: 10px !important;
- padding-bottom: 10px !important;
- position: relative!important;
- background-color: #ff937a26!important;
- }
- html body .sample2 h3::after {
- content: ''!important;
- position: absolute!important;
- border-left: 20px double #ff937a !important;
- height: 100%!important;
- top: 0!important;
- right: 50px!important;
- transform: skew(-20deg)!important;
- }
- html body .sample2 h4::before {
- margin-top: -5px!important;align-content;
- height: 25px !important;
- width: 25px !important;
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12M10,18L16,12L10,6L8.6,7.4L13.2,12L8.6,16.6L10,18Z' fill='%23ff937a'%3E%3C/path%3E%3C/svg%3E")!important;
- background-size: cover;
- background-repeat: no-repeat;
- display: block;
- }
- html body .sample2 h4 {
- font-size: 22px !important;
- font-weight: bold !important;
- display: flex!important;
- align-items: center!important;
- column-gap: 8px!important;
- color: #333333!important;
- margin-bottom: 2em !important;
- }
- <p class="seotext_00">ホームページの順位を上げるためにSEO対策が必要です。</p>
CSS
- p.seotext_00 {
- text-decoration:underline;/*下線を引く*
- text-decoration-color:#FF0000;/*下線を赤色*
- }
②点線にする。
- <p>ホームページの順位を上げるために<span class="seotext_01">SEO対策が必要</span>です。</p>
CSS
- .seotext_01 {
- border-bottom:dotted;/*下線を点線にする*/
- border-color:#FF0000;
- border-width:1px;
- }
③太さを調節する。
- .seotext_02 {
- border-bottom:solid;
- border-color:#FF0000;
- border-width:5px;/*5ピクセルの太さにする*/
- }
④二重線にする。
- .seotext_03 {
- border-bottom:double;/*二重線を引く*/
- border-color:#FF0000;
- border-width:3px;
- }
⑤位置を調整する。
- seotext_04 {
- text-decoration:underline;/*下線を引く*/
- text-underline-position:above;/*下線の位置をテキストの上に引く*/
- }
⑥マーカー風に引く
- .seotext_05 {
- background:linear-gradient(transparent 70%, #FFFF00 0%);
- }
⑦下線として波線を引く
- .seotext_06 {
- text-decoration:underline;/*下線を引く*/
- text-decoration-style:wavy;/*下線を波線で表示*/
- }
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes">
- <link rel="icon" href="img/ファビコン.ico">
- <title>トップページ|トップページ</title>
- <link rel="stylesheet" href="../index.css">
- </head>
- <body background="img/img001.gif">
- <a href="../index.html"><img src="img/welcome.gif"></a>
- <br>
- <a href="../index.html"style="text-decoration:none;"><c style="color:#556b2f;">タイトル</c></a>
- <a href="../category.html"style="text-decoration:none;"><c style="color:#556b2f;">タイトル</c></a>
- <a href="../contact.html"style="text-decoration:none;"><c style="color:#556b2f;">タイトル </c></a>