Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Jquery] [JavaScript] Pionowa lista rozwijana
Jokeer
post 2.12.2014, 21:36:39
Post #1





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 2.06.2008

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


Cześć wszystkim,

mój problem jest tematem dość znanym. Udało mi się znaleźć kilka rozwiązań niestety żadnego nie mogę dostatecznie zmodyfikować, żeby pasował do mojego kodu. Chodzi mi o zrobienie pionowego rozwijanego menu. Próbowałem metod z .css i jquery, gdzie w większości dodawany jest parametr

ul {visibility: hidden;} a mój kod menu prezentuje się nastepująco:

  1. <div id="templatemo_menu_wrapper">
  2.  
  3. <div id="templatemo_menu">
  4.  
  5. <ul>
  6. <li><a href="#"><span></span>Strona główna</a></li>
  7. <li><a href="#" target="_parent"><span></span>O nas</a></li>
  8. <li><a href="#" target="_parent"><span></span>Galeria</a></li>
  9. <li><a href="#" target="_parent"><span></span>NSP 1</a></li>
  10. <li><a href="#" target="_parent"><span></span>NSP 2</a></li>
  11. <li><a href="#" target="_parent" class="last"><span></span>Kontakt</a></li>
  12. </ul>
  13.  
  14. </div> <!-- end of templatemo_menu -->
  15.  
  16. </div> <!-- end of templatemo_menu_wrapper -->


Styl tej częśći wygląda tak:

  1. #templatemo_menu_wrapper {
  2. width: 100%;
  3. height: 120px;
  4. margin: 0 auto;
  5. background: url(../../images/templatemo_menu_bg_wrapper.jpg) no-repeat center top;
  6. }
  7.  
  8. #templatemo_menu {
  9. width: 1190px;
  10. height: 70px;
  11. margin: 0 auto;
  12. padding-top: 20px;
  13. background: url(../../images/templatemo_menu_bg_wrapper.jpg) no-repeat center top;
  14. }
  15.  
  16. #templatemo_menu_gora {
  17. width: 1190px;
  18. height: 40px;
  19. margin: 0 auto;
  20. padding-top: -20px;
  21.  
  22. }
  23.  
  24. #templatemo_menu ul {
  25. width: 930px;
  26. margin: 0px auto;
  27. padding: 0px;
  28. list-style: none;
  29. }
  30.  
  31. #templatemo_menu ul li {
  32. padding: 0px;
  33. margin: 0px;
  34. display: inline;
  35. }
  36.  
  37. #templatemo_menu ul li a {
  38. position: relative;
  39. float: left;
  40. display: block;
  41. width: 130px;
  42. margin-right: 2px;
  43. height: 50px;
  44. padding: 29px 0 0 0;
  45. text-align: center;
  46. font-size: 16px;
  47. text-decoration: none;
  48. color: #ffffff;
  49. font-weight: bold;
  50. outline: none;
  51. }
  52.  
  53. #templatemo_menu ul li a span {
  54. position: absolute;
  55. top : 0px;
  56. right: -2px;
  57. width: 2px;
  58. height: 70px;
  59. background: url(../../images/templatemo_divider.png) right no-repeat;
  60. }
  61.  
  62. #templatemo_menu li a:hover, #templatemo_menu li .current {
  63. background: url(../../images/templatemo_menu_mouse_hover.png) center no-repeat;
  64. }
  65.  
  66. #templatemo_menu li .last span {
  67. background: none;
  68. }


Potrzebuje zrobić dodatkowe, rozwijane opcje dostępne dla:
  1. <li><a href="#" target="_parent"><span></span>NSP 1</a></li>
  2. <li><a href="#" target="_parent"><span></span>NSP 2</a></li>


Jak widać całe moje menu jest oparte na elemencie <ul>, dlatego nie mogę ustawić go na hidden, bo zwyczajne nic wtedy nie widać.

Czy zielony w tym temacie może liczyć na Waszą pomoc? smile.gif

Ten post edytował Jokeer 2.12.2014, 21:37:13
Go to the top of the page
+Quote Post
trueblue
post 3.12.2014, 08:40:41
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


http://jsfiddle.net/nx03pgzt/


--------------------
Go to the top of the page
+Quote Post
Jokeer
post 3.12.2014, 20:32:48
Post #3





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 2.06.2008

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


Po pierwsze dziękuje za zainteresowanie!!!

Po drugie, jednak kiedy zastosowałem to rozwiązanie u siebie to menu w ogóle się nie wyświetla sad.gif

Zapewne jest to wina:

  1. #templatemo_menu ul{
  2. display:none;
  3. }


Moje menu wygląda teraz tak:

  1. <div id="templatemo_menu_wrapper">
  2.  
  3. <ul id="templatemo_menu">
  4.  
  5. <ul>
  6. <li><a href="#"><span></span>Strona główna</a></li>
  7. <li><a href="#" target="_parent"><span></span>O nas</a></li>
  8. <li><a href="#" target="_parent"><span></span>Galeria</a></li>
  9. <li><a href="#" target="_parent"><span></span>NSP 1</a>
  10. <ul>
  11. <li><a href="#" target="_parent"><span></span>Test</a></li>
  12. </ul>
  13. </li>
  14. <li><a href="#" target="_parent"><span></span>NSP 2</a></li>
  15. <li><a href="#" target="_parent" class="last"><span></span>Kontakt</a></li>
  16. </ul>
  17.  
  18. </ul> <!-- end of templatemo_menu -->
  19.  
  20. </div> <!-- end of templatemo_menu_wrapper -->


Plik css natomiast:
  1. #templatemo_menu_wrapper {
  2. width: 100%;
  3. height: 120px;
  4. margin: 0 auto;
  5. background: url(../../images/templatemo_menu_bg_wrapper.jpg) no-repeat center top;
  6. }
  7.  
  8. #templatemo_menu {
  9. width: 1190px;
  10. height: 70px;
  11. margin: 0 auto;
  12. padding-top: 20px;
  13. background: url(../../images/templatemo_menu_bg_wrapper.jpg) no-repeat center top;
  14. }
  15.  
  16. #templatemo_menu_gora {
  17. width: 1190px;
  18. height: 40px;
  19. margin: 0 auto;
  20. padding-top: -20px;
  21.  
  22. }
  23.  
  24. #templatemo_menu ul {
  25. width: 930px;
  26. margin: 0px auto;
  27. padding: 0px;
  28. list-style: none;
  29. }
  30.  
  31. #templatemo_menu ul li {
  32. padding: 0px;
  33. margin: 0px;
  34. display: inline;
  35. }
  36.  
  37. #templatemo_menu ul li a {
  38. position: relative;
  39. float: left;
  40. display: block;
  41. width: 130px;
  42. margin-right: 2px;
  43. height: 50px;
  44. padding: 29px 0 0 0;
  45. text-align: center;
  46. font-size: 16px;
  47. text-decoration: none;
  48. color: #ffffff;
  49. font-weight: bold;
  50. outline: none;
  51. }
  52.  
  53. #templatemo_menu ul li a span {
  54. position: absolute;
  55. top : 0px;
  56. right: -2px;
  57. width: 2px;
  58. height: 70px;
  59. background: url(../../images/templatemo_divider.png) right no-repeat;
  60. }
  61.  
  62. #templatemo_menu li a:hover, #templatemo_menu li .current {
  63. background: url(../../images/templatemo_menu_mouse_hover.png) center no-repeat;
  64. }
  65.  
  66. #templatemo_menu li .last span {
  67. background: none;
  68. }
  69. ul{
  70. margin:0;
  71. padding:0;
  72.  
  73. }
  74. #templatemo_menu>li{
  75. list-style:none;
  76. float:left;
  77. }
  78. #templatemo_menu ul{
  79. display:none;
  80. }
  81. #templatemo_menu li:hover>ul{
  82. display:block;
  83. }


Nie potrafie wyeliminować <ul> na początu menu a widzę, że to powoduje problemy.

Czy mogę prosić o pomoc jeszcze raz? Co mogę jeszcze zmodyfikować, żeby to zadziałało?

Dzięki!!!
Pozdrawiam.
Go to the top of the page
+Quote Post
trueblue
post 3.12.2014, 22:35:57
Post #4





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


ul na pewno nie może być bezpośrednim dzieckiem ul.
Poczytaj trochę więcej o html i css.
http://jsfiddle.net/xe4u3vjo/


--------------------
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 Wersja Lo-Fi Aktualny czas: 16.07.2025 - 09:53