SUPERmerci pour ta ténacité
40 posts !
respect![]()
J'essaye de te rattraper !
oupss!!
une derniere chose comment on change la couleur bleu foncé de fond par defaut a tout les navigateurs celle qu'on voit quand on passe avec la souris d'une option a l'autre.
pas accessible avec javascript c'est dans les paramètres de l'os ...
en général par défaut c'est la couleur complémentaire ...
Maintenant si tu veux vraiment tout paramétrer, il existe des selects émulés à base de ul et de li ...
du coup les ul et li acceptant le onmouseover tu fais ce que tu veux ...
ha ben tu me coupes l'herbe sous le pied spaffy![]()
voila ce que j'avais commencé il y a quelques temps :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document sans nom</title> <style type="text/css"> #contenu{ background-color:#FFFFFF; list-style:none; margin:0px; padding:0px; overflow-x:hidden; overflow-y:auto; } #contenu li{ display:block; clear:both; } .ItemSelected{ background-color:#00FF00; } .SpanitemSelected{ border-left:1px solid #dbdfe6; border-right:1px solid #dbdfe6; border-bottom:1px solid #dbdfe6; border-top:1px solid #abadb3; display:block; font-size:small; background-image:url(bgBoxSelect.jpg); background-position:top right; background-repeat:no-repeat; padding:1px; overflow-y:hidden; height:16px; } .SpanitemSelectedHover{ border-left:1px solid #c7e2f1; border-right:1px solid #5794bf; border-bottom:1px solid #c7e2f1; border-top:1px solid #5794bf; display:block; font-size:small; background-image:url(bgBoxSelectHover.jpg); background-position:top right; background-repeat:no-repeat; padding:1px; overflow-y:hidden; height:16px; } .NoSelected{ background-color:#ffffff; } #contenant{ overflow:hidden; position:absolute; height:0px; width:200px; background-color:#FFFFFF; border-left:1px solid #b2b2b2; border-right:1px solid #000000; border-bottom:1px solid #000000; border-top:1px solid #b2b2b2; visibility:hidden; margin-top:1px } .OverItem{ background-color:#3399ff; color:#FFFFFF; } .OutItem{ background-color:#FFFFFF; color:#000000; } </style> <script type="text/javascript"> var MonTimer = null; var Debut = null; var elem = null; var ajoutX = null; var ajoutY = null; var X = 0 ; var objModif; function initAnimation(Ynew){ objModif = document.getElementById('contenant'); objModif.style.visibility = 'visible'; var Yold = parseInt(document.getElementById('contenant').style.height) ; //On détruit le timer s'il existe clearTimeout(MonTimer); elem = document.getElementById('contenant'); ajoutY = (Ynew >= Yold) ? true:false; var ie=document.all; divAnime(Ynew,Yold); } function divAnime(Ynew,Yold){ X++; //si Ynew > Yold if(parseInt(elem.style.height) < Ynew && ajoutY){ elem.style.height = (parseInt(elem.style.height) + 10)+"px"; } //si Xnew < Xold else if(parseInt(elem.style.height) > Ynew){ elem.style.height = (parseInt(elem.style.height) - 10 )+"px"; } else{ elem.style.height = Ynew +"px"; } TailleFinaleY = (parseInt(elem.style.height) == Ynew) ? true:false; if(!TailleFinaleY){ MonTimer = setTimeout ('divAnime('+Ynew+','+Yold+')',1); } else{ //On tue le timer elem.style.height = ((ajoutY) ? Ynew:0) +"px"; objModif.style.visibility = ((ajoutY) ? 'visible':'hidden'); clearTimeout(MonTimer); } } function ajouterLi(TextToAdd,indexItem){ var d = document; var NewLi = d.createElement('li'); var NewTexte = d.createTextNode(TextToAdd); //Ajout du texte de l'item de la liste NewLi.appendChild(NewTexte); NewLi.onclick = function(){selectItem(indexItem,this)}; NewLi.onmouseover = function(){overStyle(this,"over")}; NewLi.onmouseout = function(){overStyle(this,"out")}; var objUL = document.getElementById( 'contenu' ); //On ajoute l'item en tout premier objUL.appendChild(NewLi); } function selectItem(indexItem,ItemToSelect){ var MesLi = document.getElementById("contenu").getElementsByTagName("li"); var nbOption= MesLi.length; for(var i = 0 ; i < nbOption ; i++){ MesLi[i].className = "NoSelected"; } ItemToSelect.className = "ItemSelected"; document.getElementById('desItems').selectedIndex = indexItem; document.getElementById('SpanitemSelected').getElementsByTagName('span')[0].innerHTML = ItemToSelect.innerHTML; initAnimation(0); } function overStyle(ItemToSelect,mode) { if(mode == "over" && ItemToSelect.className != "ItemSelected") { ItemToSelect.className = "OverItem"; } else if(mode == "out" && ItemToSelect.className != "ItemSelected") { ItemToSelect.className = "OutItem"; } } </script> </head> <body> <div href="#" style="position:relative;cursor:pointer;width:150px;float:left;" id="toto" onmouseover="initAnimation(document.getElementById('contenu').offsetHeight)" onmouseout="initAnimation(0)"> <span id="SpanitemSelected" class="SpanitemSelected" onclick="initAnimation(document.getElementById('contenu').offsetHeight)" onmouseover="this.className ='SpanitemSelectedHover'" onmouseout="this.className='SpanitemSelected'"><span style="display:block;width:90%;overflow:hidden">Selectionner une option</span></span> <div id="contenant" style="height:0px;"> <ul id="contenu"> </ul> </div> </div> <select id="desItems"> <option value="Item 1">Item 1 et la un truc super grand ça donne quoi ça merde ?</option> <option value="Item 2">Item 2</option> <option value="Item 3">Item 3</option> <option value="Item 4">Item 4</option> <option value="Item 4">Item 4</option> <option value="Item 4">Item 4</option> </select><br /><br /><br /><br /><br /><br /> <div id="debug"></div> <script type="text/javascript"> var MonSelect = document.getElementById("desItems"); var nbOption= MonSelect.length; for(var i = 0 ; i < nbOption ; i++){ ajouterLi(MonSelect[i].text,i); } document.getElementById('contenu').style.height = (i+1) * 20 + "px"; var MonSelect = document.getElementById("toto"); //MonSelect.onmouseover = doSomething; </script> </body> </html>
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager