Bonjour,

Alors, j'essaye d'ecrire un texte d'une couleur en fonction du fond d'ecran , j'ai ma fonction javascript qui permet cela :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
function RGBtoHEX()
{
   var strTot = "#";
   var str = "";
   var i;
   i = Math.round(this.r * 255); str = i.toString(16); if (str.length == 1) str = "0" + str; strTot += str;
   i = Math.round(this.g * 255); str = i.toString(16); if (str.length == 1) str = "0" + str; strTot += str;
   i = Math.round(this.b * 255); str = i.toString(16); if (str.length == 1) str = "0" + str; strTot += str;
   strTot = strTot.toUpperCase();
   return strTot;
}
Ma question est , est ce que je peux insérer cette fonction dans une partie css, mon css est :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
<style type="text/css">
.caption     { position: absolute; visibility: hidden; font-family: Tahoma; color: #000066; 
               font-size: 11px; text-align: Center; cursor: default; z-index: 
               1 }
J'aimerais remplacer "color:#000066" par "color:RGBtoHEX()" , est ce possible?
Si ce n'est pas possible, et à mon avis, c'est le cas, y a t-il une fonction en CSS permettant cela?

Merci