Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML]Problem z powieleniem kodu.
VeParadox
post
Post #1





Grupa: Zarejestrowani
Postów: 154
Pomógł: 0
Dołączył: 29.08.2012

Ostrzeżenie: (0%)
-----


Witam.
Mam taki kod , który robi dymek z obrazkiem po najechaniu kursorem. Oto on:

Kod
<img src="obrazek1.png" onmouseover="document.getElementById('dymek').style.display = ''" onmouseout="document.getElementById('dymek').style.display = 'none'"> <div id="dymek" style="position: absolute; top: 50px; left: 50%; display: none">
<img src="obrazek2.jpg">
</div>

Problem pojawia się gdy powielam kod, tak aby mieć kilka obrazków z dymkiem obok siebie. Wszystkie obrazki działają na dymek z pierwszego obrazka. Jak to rozdzielić aby indywidualnie funkcjonowało - każdy obrazek pokazywał swój dymek po najechaniu kursorem?questionmark.gif Bardzo proszę o pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
viking
post
Post #2





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


<img><div class="dymek">

css:

img+div.dymek {display:none}
img:hover+div.dymek {display:block}


--------------------
Go to the top of the page
+Quote Post
VeParadox
post
Post #3





Grupa: Zarejestrowani
Postów: 154
Pomógł: 0
Dołączył: 29.08.2012

Ostrzeżenie: (0%)
-----


Cytat(viking @ 29.08.2012, 11:20:46 ) *
<img><div class="dymek">

css:

img+div.dymek {display:none}
img:hover+div.dymek {display:block}


Albo robię coś źle, albo nie działa... Mógłbyś mi to bardziej naświetlić?
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #4





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

Ostrzeżenie: (0%)
-----


Jeśli wszystkie Twoje obrazki mają:

  1. <img src="obrazek1.png" onmouseover="document.getElementById('dymek').style.display = ''" onmouseout="document.getElementById('dymek').style.display = 'none'"> <div id="dymek" style="position: absolute; top: 50px; left: 50%; display: none">


w miejscu wywołania funkcji document.getElementById('dymek') oznacza to, że na który byś nie najechał to funkcja działa dla obiektu o id dymek, musisz im nadać kolejne wartość i id, czyli np. dymek1, dymek2, dymek3, itd.

  1. <img src="obrazek1.png" onmouseover="document.getElementById('dymek').style.display = ''" onmouseout="document.getElementById('dymek').style.display = 'none'"> <div id="dymek" style="position: absolute; top: 50px; left: 50%; display: none">
  2. <img src="obrazek2.png" onmouseover="document.getElementById('dymek1').style.display = ''" onmouseout="document.getElementById('dymek1').style.display = 'none'"> <div id="dymek1" style="position: absolute; top: 50px; left: 50%; display: none">


Coś w ten deseń.


--------------------
Jeśli pomogłem, kliknij proszę 'pomógł'. Dzięki.
Go to the top of the page
+Quote Post
viking
post
Post #5





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Cytat(VeParadox @ 29.08.2012, 11:46:44 ) *
Albo robię coś źle, albo nie działa... Mógłbyś mi to bardziej naświetlić?

To pokaż jak robisz.


--------------------
Go to the top of the page
+Quote Post
VeParadox
post
Post #6





Grupa: Zarejestrowani
Postów: 154
Pomógł: 0
Dołączył: 29.08.2012

Ostrzeżenie: (0%)
-----


Działa!! Jesteście suuuper!!!!! Wielkie THX biggrin.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 14:52