CSSの主なプロパティ一覧について

トモジのアイコン画像トモジ

CSSのプロパティって
どんなのがあるの・・・?

本記事は、
上記のような方に向けて記事を書いています。

こんにちは、トモジです。

私はプログラミング未経験から独学で勉強して、
簡易的な動的サイト・ゲーム・サービスが作れる状態になりました。

本記事は、CSSのプロパティに関して要点をわかりやすく説明しております。

記事の内容

1.CSSの主なプロパティ一覧について

CSSのスタイル変更のプロパティは
100個以上もあるので
使用頻度が高めな
プロパティをピックアップして以下の
3つの項目を細かく紹介します。

今回の紹介
  • 文字色や背景色の指定
  • 背景画像の指定
  • フォントの指定

2.文字色や背景色

表記の通り文字色と背景色を変更するために
必要なプロパティの説明をしていきます。

※色の指定方法がわからない場合は以下を参照

color(文字色の設定)

colorプロパティは文字の色を指定します。

colorプロパティに関しての図
colorプロパティ
<p>文字の色を変更</p>
p {color:red}
表示画面

文字の色を変更

background-color(背景色を設定)

background-colorプロパティは、
背景色を指定します。

background-colorに関しての図
colorプロパティ
<p>背景色を変更</p>
p {background-color:red}
表示画面

背景色を変更

3.背景画像の指定

背景画像の指定は、
画像の貼り付けや配置に関して説明していきます。

background-image(画像表示)

background-imageプロパティは、
背景画像を指定します。

background-imageに関しての図
colorプロパティ
<p></p>
p {
  background-image: url(○○/○○.拡張子) /* 画像リンク先/画像名.拡張子 */
  width:  画像の横幅サイズ              /* 画像サイズ指定(横幅) */
  height: 画像の縦幅サイズ              /* 画像サイズ指定(縦幅) */
}
表示画面

初期設定では、
画像は繰り返し表示になります。

background-repeat
(背景画像の並び方を指定)

background-repeatプロパティは、
画像の繰り返し表示に関して指定し
以下の4種類から選択できます。

background-repeatに関して
repeat縦横タイル状に繰り返して表示(初期値)
repeat-x横方向のみ繰り返して表示
repeat-y縦方向のみ繰り返して表示
no-repeat繰り返さずにひとつだけ表示

※タブを選択すると4種類の違いが確認できます。

<p></p>
p {
  background-image: url(○○/○○.拡張子);
  background-repeat: repeat;         /* 縦横タイル状に繰り返し */
  height: 100px;                     /* 画像サイズ指定(縦幅) */
  width:  100%;                      /* 画像サイズ指定(横幅) */
}
画面表示

4.フォントの指定

フォント指定は、
以下の5種類を使用する場合が多いです。

fontに関して
font-style(斜体)
text-decoration
(装飾)
文字の傾け具合とデザイン
font-weight(太さ)文字の太さの違い
font-size(サイズ)文字のサイズ
line-height(行間)文書の行間の高さ
font-family(フォント名)文字のデザイン

font-style(斜体)
text-decoration(装飾)

font-styleプロパティとtext-decorationプロパティで指定できる属性は以下の種類になります。

font-styleとtext-decorationについての図
スタイル属性簡易説明
font-stylenormal通常の斜体
font-styleitalic続け書きに近い書体
font-styleobliqueフォントを少し傾けた
text-decorationnone装飾なし
text-decorationunderline下線
text-decorationline-through取り消し線
text-decorationoverline上線
text-decorationunderline overline上下線
text-decorationunderline solid 色指定色の下線
text-decorationunderline double二重下線
text-decorationunderline dotted点線の下線
text-decorationunderline dashed破線の下線
text-decorationunderline wavy波線の下線
font-styleプロパティとtext-decorationプロパティ
<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に関しての図
font-weightプロパティ
<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に関しての図
指定方法簡易説明
単位付き数値指定した数値でフォントサイズが変わる
%指定した要素親に対しての割合で変わる
smaller要素親に対して1段階サイズが小さくなる
larger要素親に対して1段階サイズが大きくなる
xx-smallx-smallの1/1.2倍サイズ
x-smallsmallの1/1.2倍サイズ
smallmediumの1/1.2倍サイズ
medium標準サイズ
largemediumの1.2倍サイズ
x-largelargeの1.2倍サイズ
xx-largex-largeの1.2倍サイズ
font-sizeプロパティ
<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に関しての図
line-heightプロパティ
<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に関しての図
フォントの種類簡易説明
serif明朝系 (Times New Roman,MS P明朝など)
sans-serifゴシック系 (Helvetica,MS Pゴシックなど)
cursive草書体・筆記体系 (Caflisch Script,Adobe Poeticaなど)
fantasy装飾的なフォント (Critter,Cottonwoodなど)
monospace等幅フォント (MSゴシック,Osaka-等幅など)
font-familyプロパティ
<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
    フォントを指定

記事の内容
閉じる