Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CSS][JavaScript] Problem z z index dla obrazka
Woytek950
post
Post #1





Grupa: Zarejestrowani
Postów: 130
Pomógł: 2
Dołączył: 6.06.2008
Skąd: jesteś ?

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


Witam. Mam problem z z-index i wygląda on następująco:
dlaczego ta prosta funkcja nie "wyrzuci" obrazka nr 3 na sam wierzch?
  1. function changeStyleOnHover()
  2. {
  3.  
  4. document.getElementById("imgThird").style.zIndex='5';
  5. }
  6.  
  7.  
  8. <div onmouseover="changeStyleOnHover()">div<div>
  9. <img src="1.jpg" alt="" style="z-index: 4;" id="imgFirst" />
  10. <img src="2.jpg" alt="" style="z-index: 4;" id="imgSecond" />
  11. <img src="3.jpg" alt="" style="z-index: 4;" id="imgThird" />


Ten post edytował Woytek950 3.12.2011, 19:01:51
Go to the top of the page
+Quote Post
amii
post
Post #2





Grupa: Zarejestrowani
Postów: 728
Pomógł: 76
Dołączył: 12.06.2009

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


Ustaw pozycjonowanie dla elementów, po za tym jeśli nie zmieniasz położenia to nic nie zobaczysz:
Przetestuj to:

  1. <script type="text/javascript">
  2. function changeStyleOnHover()
  3. {
  4.  
  5. var doc = document.getElementById("imgThird");
  6. doc.style.zIndex='9999';
  7. doc.style.left = -10;
  8. doc.style.top = -10;
  9.  
  10. }
  11. </script>
  12.  
  13. <div onmouseover="changeStyleOnHover()">div<div>
  14. <img src="1.jpg" alt="" style="z-index: 2; position:absolute; " id="imgFirst" />
  15. <img src="2.jpg" alt="" style="z-index: 3; position:absolute; " id="imgSecond" />
  16. <img src="3.jpg" alt="" style="z-index: 4; position:absolute; left:100px; " id="imgThird" />
  17.  
  18. </body>
  19. </html>


tutaj: http://www.w3schools.com/js/tryit.asp?filename=tryjs_events
Go to the top of the page
+Quote Post
Woytek950
post
Post #3





Grupa: Zarejestrowani
Postów: 130
Pomógł: 2
Dołączył: 6.06.2008
Skąd: jesteś ?

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


Zapomniałem napisac ale wszystkie obrazki były w pozycji absolute i jeden na drugim

Edit: dopiero teraz się skapnąłem że obrazek miał w stylach ustawione na display:none; męczyłem się z tym 3h.


Ten post edytował Woytek950 3.12.2011, 19:50:08
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 28.08.2025 - 20:13