背景画像(壁紙)

トップ > 逆引きリファレンス > 背景画像

背景画像を張るには

<body> タグに background 属性を指定します。

<body background="back.gif">

スタイルシートの場合は background-image を用います。

<style type="text/css">
<!--
body { background-image: url(back.gif); }
-->
</style>

背景画像を固定するには

画面をスクロールさせても、背景画像だけはスクロールしないようにするには、<body> タグに bgproperties="fixed" 属性を指定します。

<body background="back.gif" bgproperties="fixed">

背景画像を縦(横)方向にのみ並べるには

背景画像は通常、縦方向、横方向双方にタイル状に並べられますが、スタイルシートの background-repeat を用いることでこれを縦方向のみ、もしくは横方向のみに並べることができます。repeat-y は縦方向のみ、repeat-x は横方向のみに並べます。

<style type="text/css">
<!--
body {
  background-image: url(back.gif);
  background-repeat: repeat-y;
}
-->
</style>

背景画像をひとつのみ表示するには

背景画像をひとつのみ表示するには、background-repeat を用います。また、background-position でその位置を指定することもできます。

<style type="text/css">
<!--
body {
  background-image: url(back.gif);
  background-repeat: no-repeat;
  background-position: center center;
}
-->
</style>

Copyright (C) 2003 杜甫々
初版: 2003年10月12日
http://www.tohoho-web.com/how2/image.htm