![トモジのアイコン画像](https://10moji-blog.com/wp-content/uploads/2020/08/吹き出しトモジ.png)
CSSのプロパティって
どんなのがあるの・・・?
本記事は、
上記のような方に向けて記事を書いています。
こんにちは、トモジです。
私はプログラミング未経験から独学で勉強して、
簡易的な動的サイト・ゲーム・サービスが作れる状態になりました。
本記事は、CSSのプロパティに関して要点をわかりやすく説明しております。
1.CSSの主なプロパティ一覧について
CSSのスタイル変更のプロパティは
100個以上もあるので
使用頻度が高めな
プロパティをピックアップして以下の
3つの項目を細かく紹介します。
- 文字色や背景色の指定
- 背景画像の指定
- フォントの指定
2.文字色や背景色
表記の通り文字色と背景色を変更するために
必要なプロパティの説明をしていきます。
※色の指定方法がわからない場合は以下を参照
color(文字色の設定)
colorプロパティは文字の色を指定します。
![colorプロパティに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/dbcfec2a6e8e2c984cfb507b7d86fd9f-1024x942.png)
<p>文字の色を変更</p>
p {color:red}
文字の色を変更
background-color(背景色を設定)
background-colorプロパティは、
背景色を指定します。
![background-colorに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/background-color-1024x942.png)
<p>背景色を変更</p>
p {background-color:red}
背景色を変更
3.背景画像の指定
背景画像の指定は、
画像の貼り付けや配置に関して説明していきます。
background-image(画像表示)
background-imageプロパティは、
背景画像を指定します。
![background-imageに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/ddb7a9f1f610c49a269526a3c58d4f71-1024x942.png)
<p></p>
p {
background-image: url(○○/○○.拡張子) /* 画像リンク先/画像名.拡張子 */
width: 画像の横幅サイズ /* 画像サイズ指定(横幅) */
height: 画像の縦幅サイズ /* 画像サイズ指定(縦幅) */
}
初期設定では、
画像は繰り返し表示になります。
background-repeat
(背景画像の並び方を指定)
background-repeatプロパティは、
画像の繰り返し表示に関して指定し
以下の4種類から選択できます。
repeat | 縦横タイル状に繰り返して表示(初期値) |
repeat-x | 横方向のみ繰り返して表示 |
repeat-y | 縦方向のみ繰り返して表示 |
no-repeat | 繰り返さずにひとつだけ表示 |
※タブを選択すると4種類の違いが確認できます。
<p></p>
p {
background-image: url(○○/○○.拡張子);
background-repeat: repeat; /* 縦横タイル状に繰り返し */
height: 100px; /* 画像サイズ指定(縦幅) */
width: 100%; /* 画像サイズ指定(横幅) */
}
4.フォントの指定
フォント指定は、
以下の5種類を使用する場合が多いです。
font-style(斜体) text-decoration (装飾) | 文字の傾け具合とデザイン |
font-weight(太さ) | 文字の太さの違い |
font-size(サイズ) | 文字のサイズ |
line-height(行間) | 文書の行間の高さ |
font-family(フォント名) | 文字のデザイン |
font-style(斜体)
text-decoration(装飾)
font-styleプロパティとtext-decorationプロパティで指定できる属性は以下の種類になります。
![font-styleとtext-decorationについての図](https://10moji-blog.com/wp-content/uploads/2021/01/93816f06302fc7c89b2cdcfeda9e44fe-1024x942.png)
スタイル | 属性 | 簡易説明 |
---|---|---|
font-style | normal | 通常の斜体 |
font-style | italic | 続け書きに近い書体 |
font-style | oblique | フォントを少し傾けた |
text-decoration | none | 装飾なし |
text-decoration | underline | 下線 |
text-decoration | line-through | 取り消し線 |
text-decoration | overline | 上線 |
text-decoration | underline overline | 上下線 |
text-decoration | underline solid 色 | 指定色の下線 |
text-decoration | underline double | 二重下線 |
text-decoration | underline dotted | 点線の下線 |
text-decoration | underline dashed | 破線の下線 |
text-decoration | underline wavy | 波線の下線 |
<p> font-style : normal </p>
<p class="ital"> font-style : italic </p>
<p class="obliq"> font-style : oblique </p>
<p> text-decoration : none </p>
<p class="underl"> text-decoration : underline </p>
<p class="line"> text-decoration : line-through </p>
<p class="overl"> text-decoration : overline </p>
<p class="under-overl"> text-decoration : underline overline </p>
<p class="underl-solid"> text-decoration : underline solid 色 </p>
<p class="under-double"> text-decoration : underline double </p>
<p class="under-dotted"> text-decoration : underline dotted </p>
<p class="under-dashed"> text-decoration : underline dashed </p>
<p class="under-wavy"> text-decoration : underline wavy </p>
.ital {font-style: italic}
.obliq {font-style: oblique}
.underl {text-decoration: underline}
.line {text-decoration: line-through}
.overl {text-decoration: overline}
.under-overl {text-decoration: underline overline}
.underl-solid {text-decoration: underline solid red}
.under-double {text-decoration: underline double}
.under-dotted {text-decoration: underline dotted}
.under-dashed {text-decoration: underline dashed}
.under-wavy {text-decoration: underline wavy}
font-style : normal
font-style : italic
font-style : oblique
text-decoration : none
text-decoration : underline
text-decoration : line-through
text-decoration : overline
text-decoration : underline overline
text-decoration : underline solid red
text-decoration : underline double
text-decoration : underline dotted
text-decoration : underline dashed
text-decoration : underline wavy
font-weight(太さ)
font-weightは、フォントの太さを指定できる
プロパティになり、9種類の太さが指定できます。
しかし、ブラウザ上では2種類(通常・太文字)の
表現しかできないことがほとんどです。
※数値が高いほど太文字
![font-weightに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/12d3fe84e2bb9a661951a92f7fc80ee8-1024x942.png)
<ul>
<li> font-weight : normal </li>
<li class="bold"> font-weight : bold </li>
<li class="w100"> font-weight : 100 </li>
<li class="w200"> font-weight : 200 </li>
<li class="w300"> font-weight : 300 </li>
<li class="w400"> font-weight : 400 </li>
<li class="w500"> font-weight : 500 </li>
<li class="w600"> font-weight : 600 </li>
<li class="w700"> font-weight : 700 </li>
<li class="w800"> font-weight : 800 </li>
<li class="w900"> font-weight : 900 </li>
</ul>
.bold {font-weight: bold;}
.w100 {font-weight: 100;}
.w200 {font-weight: 200;}
.w300 {font-weight: 300;}
.w400 {font-weight: 400;}
.w500 {font-weight: 500;}
.w600 {font-weight: 600;}
.w700 {font-weight: 700;}
.w800 {font-weight: 800;}
.w900 {font-weight: 900;}
- font-weight : normal
- font-weight : bold
- font-weight : 100
- font-weight : 200
- font-weight : 300
- font-weight : 400
- font-weight : 500
- font-weight : 600
- font-weight : 700
- font-weight : 800
- font-weight : 900
[normal]は、font-weightの400
[bold]は、font-weightの700
font-size(サイズ)
font-sizeプロパティは、フォントのサイズを様々な指定方法で変更できますので見ていきましょう。
![font-sizeに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/f6343cf8739e681c5c1a662ca58500e4-1024x942.png)
指定方法 | 簡易説明 |
---|---|
単位付き数値 | 指定した数値でフォントサイズが変わる |
% | 指定した要素親に対しての割合で変わる |
smaller | 要素親に対して1段階サイズが小さくなる |
larger | 要素親に対して1段階サイズが大きくなる |
xx-small | x-smallの1/1.2倍サイズ |
x-small | smallの1/1.2倍サイズ |
small | mediumの1/1.2倍サイズ |
medium | 標準サイズ |
large | mediumの1.2倍サイズ |
x-large | largeの1.2倍サイズ |
xx-large | x-largeの1.2倍サイズ |
<ul>
<li class="xxs"> xx-smallのフォントサイズです </li>
<li class="xs"> x-smallのフォントサイズです </li>
<li class="s"> smallのフォントサイズです </li>
<li class="m"> medium(標準)のフォントサイズです </li>
<li class="l"> largeのフォントサイズです </li>
<li class="xl"> x-largeのフォントサイズです </li>
<li class="xxl"> xx-largeのフォントサイズです </li>
</ul>
<hr>
<ul>
<li class="smaller"> smallerのフォントサイズです </li>
<li> mediumのフォントサイズです </li>
<li class="large"> largerのフォントサイズです </li>
</ul>
<hr>
<ul>
<li class="p50"> 50%のフォントサイズです </li>
<li class="p80"> 80%のフォントサイズです </li>
<li class="p100"> 100%のフォントサイズです </li>
<li class="p150"> 150%のフォントサイズです </li>
</ul>
.xxs{font-size: xx-small;}
.xs{font-size: x-small;}
.s{font-size: small;}
.m{font-size: medium;}
.l{font-size: large;}
.xl{font-size: x-large;}
.xxl{font-size: xx-large;}
.smaller{font-size: smaller;}
.larger{font-size: larger;}
.p50{font-size: 50%;}
.p80{font-size: 80%;}
.p100{font-size: 100%;}
.p150{font-size: 150%;}
- xx-smallのフォントサイズです
- x-smallのフォントサイズです
- smallのフォントサイズです
- medium(標準)のフォントサイズです
- l argeのフォントサイズです
- x-largeのフォントサイズです
- xx-largeのフォントサイズです
- smallerのフォントサイズです
- mediumのフォントサイズです
- largerのフォントサイズです
- 50%のフォントサイズです
- 80%のフォントサイズです
- 100%のフォントサイズです
- 150%のフォントサイズです
line-height(行間)
line-heightプロパティは、
行の高さを指定するプロパティになります。
マイナス値は指定できなく、単位無しの数値と%表記はフォントサイズに対しての割合になります。
![line-heightに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/0689480f3e0e71843130d142ac2611f1-1024x942.png)
<p class="normal">
line-heightプロパティは、<br>
行の高さを指定するプロパティになり<br>
マイナス値は指定できなく、<br>
単位無しの数値と%表記はフォントサイズに対しての割合になります。
</p>
<hr>
<p class="l2">
line-heightプロパティは、<br>
行の高さを指定するプロパティになり<br>
マイナス値は指定できなく、<br>
単位無しの数値と%表記はフォントサイズに対しての割合になります。
</p>
<hr>
<p class="lp200">
line-heightプロパティは、<br>
行の高さを指定するプロパティになり<br>
マイナス値は指定できなく、<br>
単位無しの数値と%表記はフォントサイズに対しての割合になります。
</p>
.normal{line-height: normal;}
.l1.5{line-height: 2;}
.lp180{line-height: 200%;}
line-heightプロパティは、
行の高さを指定するプロパティになり
マイナス値は指定できなく、
単位無しの数値と%表記はフォントサイズに対しての割合になります。
line-heightプロパティは、
行の高さを指定するプロパティになり
マイナス値は指定できなく、
単位無しの数値と%表記はフォントサイズに対しての割合になります。
line-heightプロパティは、
行の高さを指定するプロパティになり
マイナス値は指定できなく、
単位無しの数値と%表記はフォントサイズに対しての割合になります。
font-family(フォント名)
font-familyプロパティは、フォントファミリー名とフォントの種類を指定して文字のデザインを変更します。
![font-familyに関しての図](https://10moji-blog.com/wp-content/uploads/2021/01/939e55245f9f606fac59a49ac7fc7088-1024x942.png)
フォントの種類 | 簡易説明 |
---|---|
serif | 明朝系 (Times New Roman,MS P明朝など) |
sans-serif | ゴシック系 (Helvetica,MS Pゴシックなど) |
cursive | 草書体・筆記体系 (Caflisch Script,Adobe Poeticaなど) |
fantasy | 装飾的なフォント (Critter,Cottonwoodなど) |
monospace | 等幅フォント (MSゴシック,Osaka-等幅など) |
<p class="family1">この文章はserifです。</p>
<p class="family2">この文章はsans-serifです。</p>
<p class="family3">この文章はcursiveです。</p>
<p class="family4">この文章はfantasyです。</p>
<p class="family5">この文章はmonospaceです。</p>
.family1 {font-family: serif;}
.family2 {font-family: sans-serif;}
.family3 {font-family: cursive;}
.family4 {font-family: fantasy;}
.family5 {font-family: monospace;}
この文章はserifです
この文章はsans-serifです。
この文章はcursiveです。
この文章はfantasyです。
この文章はmonospaceです。
環境によってフォントの日本語を認識せず、英語のみ有効になる場合があります。
まとめ
最後にこの記事のポイントをまとめておきます。
文字色や背景色
color
文字色を指定background-color
背景色を指定
背景画像の指定
background-image
画像を挿入background-repeat
画像の表示を変更
フォントの指定
font-style
文字の傾き具合を指定text-decoration
装飾を指定font-weight
文字の太さ指定font-size
文字のサイトを指定line-height
行間の高さを指定font-family
フォントを指定