ページのレイアウト
背景の設定
背景には、色や画像を指定することができます。
外部にまとめることで、各ページに全て同じ設定をすることができます。何度も書く必要もなくなり、非常に便利です。
背景に色を指定する場合
<style type="text/css">
body { background-color: #ffffff; }
</style>
body { background-color: #ffffff; }
</style>
背景に画像を指定する場合
<style type="text/css">
body { background-image: url(ファイル名); }
</style>
body { background-image: url(ファイル名); }
</style>
font-sizebackground-color: #ffffff; | 背景の色を指定します。 |
background-image: url(ファイル名); | 背景に使う画像を指定します。 |
中央揃え
文章や画像などを中央に表示させる方法です。
文章や画像を中央に表示させる場合
<style type="text/css">
body { text-align: center; }
</style>
body { text-align: center; }
</style>
テーブルを中央に表示させる場合
<style type="text/css">
table { margin-left: auto; margin-right: auto; }
</style>
table { margin-left: auto; margin-right: auto; }
</style>
text-align: center; | テキストを中央に表示します。right に変えると右側に、left に変えると左側に表示できます。 |
margin | 余白の設定です。auto は自動という意味で、中央表示させることができます。 |