Menüaufbau

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Hey zusammen,

    Ich habe da was gesehen, das hat mir unheimlich gut gefallen, wollte es sodann nachbauen, aber scheitere daran leider. Habe es mit jquery, js, und ajax versucht, aber irgendwie hakt es immer irgendwo.

    Hier mal was ich bisher geschafft habe:

    HTML-Quellcode

    1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2. <html>
    3. <head>
    4. <style type="text/css">
    5. <!--
    6. .lay {
    7. display: none;
    8. position: relative;
    9. }
    10. p
    11. {
    12. background:yellow;
    13. width:980px;
    14. height:300px;
    15. }
    16. -->
    17. </style>
    18. <script>
    19. n = 3; // number of hidden layers
    20. function show(a){
    21. for(i=1;i<=n;i++){
    22. document.getElementById('t'+i).style.display = 'none';
    23. }
    24. document.getElementById('t'+a).style.display = 'inline';
    25. }
    26. </script>
    27. </head>
    28. <body>
    29. <div style="position:relative">
    30. <a href="#" onmouseover="show(1)">link 1</a>
    31. <a href="#" onmouseover="show(2)">link 1</a>
    32. <a href="#" onmouseover="show(3)">link 1</a>
    33. <div id="t1" class="lay"><p><a href="www.google.de">Google</a></p> </div>
    34. <div id="t2" class="lay"><p>222 some comment here<br>some some <br>asdgag</p></div>
    35. <div id="t3" class="lay"><p>333 some comment here some some </p></div>
    36. </div>
    37. </body>
    38. </html>
    Alles anzeigen


    Was ich jetzt noch möchte ist das ich wenn ich aus den Links oder eben dem div mit der Maus rausgehe soll das div wieder verschwinden, aber das will irgendwie ned :(

    Hier übrigens noch der Link zum Original:

    ladenzeile.de <= Das Menü oben - das hätt ich eben gern genau so :)

    Merci für's drüberschaun!

    Gruß,
    Matthias
    Das Leben ist binär - du bist eine 1, oder eine 0
  • Ich bin wahrlich kein JavaScript-Crack. Aber wenn du schon eine Funktion zum Einblenden hast, kannst du doch auch eine zum Ausblenden nutzen:

    Quellcode

    1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2. <html>
    3. <head>
    4. <style type="text/css">
    5. <!--
    6. .lay {
    7. display: none;
    8. position: relative;
    9. }
    10. p
    11. {
    12. background:yellow;
    13. width:980px;
    14. height:300px;
    15. }
    16. -->
    17. </style>
    18. <script>
    19. n = 3; // number of hidden layers
    20. function show(a){
    21. for(i=1;i<=n;i++){
    22. document.getElementById('t'+i).style.display = 'none';
    23. }
    24. document.getElementById('t'+a).style.display = 'inline';
    25. }
    26. function hide(a){
    27. document.getElementById('t'+a).style.display = 'none';
    28. }
    29. </script>
    30. </head>
    31. <body>
    32. <div style="position:relative">
    33. <a href="#" onmouseover="show(1)" onmouseout="hide(1)">link 1</a>
    34. <a href="#" onmouseover="show(2)" onmouseout="hide(2)">link 1</a>
    35. <a href="#" onmouseover="show(3)" onmouseout="hide(3)">link 1</a>
    36. <div id="t1" class="lay"><p><a href="www.google.de">Google</a></p> </div>
    37. <div id="t2" class="lay"><p>222 some comment here<br>some some <br>asdgag</p></div>
    38. <div id="t3" class="lay"><p>333 some comment here some some </p></div>
    39. </div>
    40. </body>
    41. </html>
    Alles anzeigen
  • Quellcode

    1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2. <html>
    3. <head>
    4. <style type="text/css">
    5. <!--
    6. .lay {
    7. display: none;
    8. position: relative;
    9. }
    10. p
    11. {
    12. background:yellow;
    13. width:980px;
    14. height:300px;
    15. }
    16. -->
    17. </style>
    18. <script>
    19. function getElementsByClassName(className) {
    20. var muster = new RegExp("(^| )" + className + "($| )");
    21. var alles = document.getElementsByTagName("*");
    22. var gefunden = new Array();
    23. var i;
    24. for (i=0; i < alles.length; i++) {
    25. if (alles[i] && alles[i].className && alles[i].className != "") {
    26. if (alles[i].className.match(muster))
    27. gefunden[gefunden.length] = alles[i];
    28. }
    29. }
    30. return gefunden;
    31. }
    32. function show(a){
    33. var hiddenElements = getElementByClassName("lay");
    34. for(var i = 0; i<hiddenElements.length; i++) {
    35. hiddenElements[i].style.display = 'none';
    36. }
    37. document.getElementById('t'+a).style.display = 'inline';
    38. }
    39. function hide(){
    40. var hiddenElements = getElementByClassName("lay");
    41. for(var i = 0; i<hiddenElements.length; i++) {
    42. hiddenElements[i].style.display = 'none';
    43. }
    44. }
    45. </script>
    46. </head>
    47. <body>
    48. <div style="position:relative" onmouseout='hide()'>
    49. <a href="#" onmouseover="show(1)">link 1</a>
    50. <a href="#" onmouseover="show(2)">link 1</a>
    51. <a href="#" onmouseover="show(3)">link 1</a>
    52. <div id="t1" class="lay"><p><a href="www.google.de">Google</a></p> </div>
    53. <div id="t2" class="lay"><p>222 some comment here<br>some some <br>asdgag</p></div>
    54. <div id="t3" class="lay"><p>333 some comment here some some </p></div>
    55. </div>
    56. </body>
    57. </html>
    Alles anzeigen


    Mit diesem Code sollte es gehen (könnte Syntaxfehler enthalten, aus Kopf aufgeschrieben...)

    Dank getElementsByClassName musst du keine Variable n mehr "mitschleppen".
    </nobrain>
  • Hi zusammen,

    @n0x-f0x: Bei deinem Code passiert gar nichts? Leider kenn ich mich mit Java nicht wirklich gut aus, somit fällt es mir schwer die Syntaxfehler hier zu finden :(


    @mad: Dein Code macht eigentlich was er soll, leider passiert das hide sobald ich den Link verlasse, da es ja aber ein menü werden soll, ich also quasi auch noch in das DIV rein muss um einen Menüpunkt auszuwählen, und erst wenn ich quasi den LINK UND DAS DIV verlasse soll er den hide machen ... ihr seht ... gar nicht soooo einfach :)

    Ich bastel mal weiter, vielleicht hat aber jemand ja noch ne Idee :)

    Matthias
    Das Leben ist binär - du bist eine 1, oder eine 0