ホーム > History & Notes & Item > Notes > 2007年08月


画像のランダム表示 - 2007/08/28 (Tue)

<head>
<style type="text/css">
<!--
body{
background-attachment: fixed;
background-repeat: no-repeat;
background-position: 90% 90%;
}
-->
</style>
</head>
<body>
<script type="text/javascript">
<!--
bgimg = new Array();
bgimg[0] = "画像URL1";
bgimg[1] = "画像URL2";
bgimg[2] = "画像URL3";
bgimg[3] = "画像URL4";
bgimg[4] = "画像URL5";
chip = Math.floor(bgimg.length * Math.random());
document.body.background = bgimg[chip];
// -->
</script>
</body>

ランダムで背景画像をするには、BODY内のタグで出来ます。
ただし、BODY内だけでは背景画像が連続され、スクロールされます。
そこで固定したい時はHEAD内にあるタグをHEADに書きます。


背景画像のHTML表示について - 2007/08/28 (Tue)

<html>
<head>
<title>タイトル</title>
<style type="text/css">
<!--
body {
background-attachment: fixed;
background-image : url(画像URL);
background-repeat: no-repeat;
background-position: 0% 100%;
}
-->
</style>
</head>
<body>

画像を左下に設置したい場合は以下のようにする。

background-position: 0% 100%;




- Tor News Ver1.2 -