このページの様に背景を任意の場所に固定させる方法です。
お使いのホームページ作成ソフトなどで背景を普通に設定した後、以下の背景固定タグをhtmlソースの<head>と</head>の間に貼り付けてください。
1.背景を固定(スクロールしても背景は動かないというもの)
<style type="text/css">
body {
background-attachment:fixed;}
</style>
|
2.背景を上一行にのみ繰り返す
<style type="text/css">
body {
background-repeat:repeat-x;}
</style> |
3.背景を左一列にのみ繰り返す(2とはxとyの違いだけ)
<style type="text/css">
body {
background-repeat:repeat-y;}
</style> |
※2、3を背景固定したい場合は、それぞれの <styletype=
"text/css"> と </style> の間に1の
body {
background-attachment:fixed;} を加えれば出来ます。
4.背景を左上のみに固定
<style type="text/css">
body {
background-attachment:fixed;
background-repeat :
no-repeat;
background-position : 0%
0%;}
</style> |
※下から2行目の background-position にある 0%
0% が位置を示しています。
左上から見た%です。
100% 0% にすると右上に固定
0%
100% にすると左下に固定
100%
100% にすると右下に固定されます。
0〜100の間なら何%でもいいので、お好きな位置に固定できます。
|