この DIV は、背景色と、一組の テキスト色 ハイパーリンク色 - Google日本が切り替わります。
この表のセル色が切り替わります。
非変色セル。

非変色セル。

 

ホームへ       サンプルページ  コンテンツ色 content_color.htm

ページオープン毎に、DIV、TR の背景色などをランダムに切り替える。      DHTML。    色などのカスタマイズはテキストエディターなどで可。    Internet Explorer4.x〜 対応。     コピー、編集し、簡単にWebで応用できまっ、(^ ^)。

デモは、[F5]キーでの再読込などで。

 

< ご使用方法 >

・ ローカル(=PC)への保存は、content_color.htm を右クリック、[対象をファイルに保存] - 【ファイルのダウンロード】、【ファイル名を付けて保存】 - <保存する場所>: ……、などで。    ※: 【Internet Explorer】 - [ファイル] - [名前を付けて保存]−[ファイルの種類] ”Webページ、完全” ……、などで変わってしまったファイル名や、*.html 中のパスは要修正。

・ このDHTMLの実装方法は、content_color.htm をテキストエディターで開き、ホームページ作成ソフトなどのHTML挿入/編集メニューなどを使って、新しいページ 1 や hogehoge.html(=任意の挿入先ファイル名) の、<head> 〜</head>の任意の行間に (*1) を、さらに<body> 〜</body>の任意の行間に (*2) をペーストします。

 ・ 関連情報 : 色記号62スタイルシートリファレンスホームページ開設入門が便利!。   Web DevelopmentWeb開発MSDN IE8 HTMLとCSS

 

(*1) content_color.htm (例)        挿入先の  <head> 〜 </head>の、部分にペーストします。

HTMLの編集方法   (*1) をテキストエディターで開き、下記↓のHTMLを挿入先ファイルにペースト、太字部分を編集し使用。
〔この列ペースト不要〕

シフトJIS使用(削除不可)

ieなどに表示するアイコンファイル名(削除可)

<style type 〜</style>は(削除可)
ハイパーリンク文字色 背景色 下線
表示済みの〃
マウスオーバー時の〃
クリック中の〃

リンクを新しいWinで開くを標準(削除可)※:target= いろいろ
同じフレーム target="_self"
ページ全体  target="_top"
親フレーム  target="_parent"
お気に入り、タスクバーに表示するページ名(≠ファイル名)

 

 

 

 一組の背景色:テキスト色:ハイパーリンク色  背景色

 

 

 

 

セレクター
一組の色数=背景色・テキスト色・ハイパーリンク色 = 3色

 

 

 

<meta http-equiv="Content-Type" content="text/html; charset=x-sjis">

<link REL="SHORTCUT ICON" href="favicon.ico">

<style type="text/css"><!--
a:link { color:#55006C; background-color:#FAFAFC; text-decoration:none; }
a:visited { color:#3E0010; background-color:#F3F2F4; text-decoration:none; }
a:hover { color:#8000e2; background-color:#E8E5E9; text-decoration:underline; }
a:active { color:#E700A4; background-color:#E1DDE9; text-decoration:underline; }
-->
</style>

<base target="_blank">
<title>サンプルページ  コンテンツ色</title>

 

<!-- ☆ ----------- ↓ この間をコピー&ペーストします。 ------------ -->
<script type="text/javascript">
/***********************************************
* Random Content Colors script- ゥ Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//specify list of random background colors to apply to CSS class "randomcolor"
//For each entry, you can optionally specify a text and link color via the syntax:
// "BackgroundColor:TextColor" OR "BackgroundColor:TextColor:LinkColor"
// 一組の背景色:テキスト色:ハイパーリンク色  背景色   〃     〃    〃     〃     〃    〃
var randombgcolors=["#AA82E0:#FFFFFF:#009FA5","#DDF4FF","#FFFF97","#CFFF9F","#90D9E3","#B4B2EC","#CF4065","#D2CAE4"]

var rbcssrule=""
var randomnum=Math.floor(Math.random()*randombgcolors.length)
if (randombgcolors[randomnum].indexOf(":")!=-1){
rbcssrule="background-color: "+randombgcolors[randomnum].split(":")[0]+";"
rbcssrule+="color: "+randombgcolors[randomnum].split(":")[1]+";"
}
else
rbcssrule="background-color: "+randombgcolors[randomnum]+";"

document.write('<style type="text/css">\n')
document.write('.randomcolor{'+rbcssrule+'}\n')
if (randombgcolors[randomnum].split(":").length==3) //if link color specified
document.write('.randomcolor a{color:'+randombgcolors[randomnum].split(":")[2]+';}\n')
document.write('<\/style>')

</script>
<!-- ☆ ----------- ↑ この間をコピー&ペーストします。 ------------ -->
  

 

(*2) content_color.htm (例)        挿入先の  <body> 〜 </body> の、 部分にペーストします。

HTMLの編集方法   (*2)をテキストエディターで開き、下記↓のHTMLを挿入先ファイルにペースト、太字部分を編集し使用。
〔この列ペースト不要〕

※:<body> 部の編集 背景 リンク 表示済みリンクンク アクティブリンクの各色(任意値)

セレクター 

  

 

セレクター

 

 

 

 

<body bgcolor="#F8F5F5" link="#54006C" vlink="#62000D" alink="#00FFFF">

<!-- ★ ----------- ↓ この間をコピー&ペーストします。 ------------ -->
<table border="0" width="550px" cellspacing="0" cellpadding="0">
<tr>
<td width="40%"><div style="border: 1px solid black; padding: 3px; width: 200px; height: 150px" class="randomcolor">
この DIV は、<b>背景色</b>と、一組の<b> テキスト色</b>、<a href="http://www.google.co.jp/" target="_blank" title="新しいWinで開きます。"> <b>ハイパーリンク色 - Google日本</b></a>が切り替わります。</div></td>
<td width="60%" valign="top">
<table border="1" width="100%" cellspacing="0" cellpadding="3">
<tr>
<td class="randomcolor"><b>この表のセル色が切り替わります。</b></td>
</tr>
<tr>
<td>非変色セル。<p>非変色セル。</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ★ ----------- ↑ この間をコピー&ペーストします。 ------------ -->
 

 

< 補足 >    適時参照あれ!。

・ Wordpad によるHTMLソース(タグ)を見ながらの直接編集方法。