Menu déroulant - Programmation
TomsGuide.com : 700 000 inscrits répondent à toutes vos questions high-tech et informatique.
Pour obtenir de l'aide, inscrivez-vous gratuitement !
 




Mot :   Pseudo :  
 
Bas de page
Auteur
 Sujet : Menu déroulant
 
Profil : IDNaute
Plus d'informations

Bonjour à tous,

J'ai fait un menu déroulant (le code est plus bas) et je voudrais l'aligner à gauche. Comment faire ?

Voici le code.

Code :
  1. <style type="text/css">
  2. body{
  3.     font-family: sans-serif;
  4.     padding-left:5%;
  5.     padding-right:5%;
  6. }
  7. #logo{
  8.     font-size:2em;
  9.     border-bottom:1px dotted silver;
  10.     color:silver;
  11. }
  12. #myMenu{
  13.     float:right;
  14.     width:20%;
  15. }
  16. #content{
  17.     float:left;
  18.     width:70%;
  19.     font-size:0.8em
  20. }
  21. h3{
  22.     margin-top:0;
  23. }
  24. p{
  25. }
  26. #copyright{
  27.     clear:both;
  28.     border-top:1px solid silver;
  29.     margin-top:20px;
  30.     text-align:right;
  31.     padding-right:5px;
  32.     font-size:0.5em;
  33. }
  34. /* menu styles */
  35. li.myMenu0{
  36.     margin:0;
  37.     padding:0;
  38.     list-style : none;
  39. }
  40. a.myMenu0{
  41.     display:block;
  42.     position:relative;
  43.     background-color:white;
  44.     padding:3px;
  45.     text-decoration:none;
  46.     color:Navy;
  47.     border:1px solid blue;
  48.     margin-top:10px;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <div align="left">
  54.   <ul id="myMenu">
  55.       <li><a href="#">
  56.         Menu
  57.     </a>        <ul>
  58.         <!-- NOTE: No space between A tag and UL or IE will make space between the elements -->
  59.                 <li><a href="http://virtuailes.iquebec.com">Accueil</a></li>
  60.                 <li><a href="http://virtuailes.iquebec.com/avianews.php">News Aéronautiques</a></li>
  61.                 <li><a href="http://virtuailes.iquebec.com/index2.php">News du site</a></li>
  62.                 <li><a href="http://galerie.virtuailes.iquebec.com/">Galerie</a></li>
  63.                 <li><a href="http://virtuailes.iquebec.com/connexion.php">Connexion</a></li>
  64.         </ul>
  65.     </li>
  66.         <li>
  67.      
  68.         <a href="#">Contenu</a>
  69.               <ul>
  70.                 <li><a href="http://virtuailes.iquebec.com/script/engine.php">Recherche Interne</a></li>
  71.                 <li><a href="http://virtuailes.iquebec.com/google.php">Recherche Google</a></li>
  72.                 <li><a href="http://virtuailes.iquebec.com/dossiers.php">Dossiers</a></li>
  73.                 <li><a href="http://virtuailes.iquebec.com/creations.php">Créations</a></li>
  74.                 <li><a href="http://virtuailes.iquebec.com/fichiers.php">Téléchargements</a></li>
  75.                 <li><a href="http://galerie.virtuailes.iquebec.com/">Galerie</a></li>
  76.                 <li><a href="http://virtuailes.iquebec.com/privacypolicy.php">Copyright</a></li>
  77.           </ul>
  78.     </li>
  79.         <li>
  80.           <a href="#">Communauté</a>
  81.           <ul>
  82.               <li><a href="http://client0.sigmachat.com/sc.pl?id%3d133784">Chat</a></li>
  83.                 <li><a href="http://139968.aceboard.fr/index.php">Forum</a></li>
  84.                 <li><a href="http://virtuailes.iquebec.com/liens.php">Liens</a></li>
  85.                 <li><a href="http://virtuailes.iquebec.com/contact.php">Nous Contacter</a></li>
  86.                 <li><a href="http://vote.weborama.fr/fcgi-bin/vote.fcgi?206750">Voter au Weborama</a></li>
  87.           </ul>
  88.     </li>
  89.         <li>
  90.           <a href="#">Forum</a>
  91.           <ul>
  92.               <li><a href="http://139968.aceboard.fr/139968-867-0-Annonces.htm">Annonces</a></li>
  93.                 <li><a href="http://139968.aceboard.fr/139968-1443-0-Bistrot.htm">Le Bistrot</a></li>
  94.                 <li><a href="http://139968.aceboard.fr/139968-863-0-Sondages.htm">Sondages</a></li>
  95.                 <li><a href="http://139968.aceboard.fr/139968-1686-0-Actualite.htm">Actualité</a></li>
  96.                 <li><a href="http://139968.aceboard.fr/139968-1662-0-Dossiers.htm">Dossiers</a></li>
  97.                 <li><a href="http://139968.aceboard.fr/139968-1436-0-rapport-avec-aviation.htm">En rapport avec l'aviation</a></li>
  98.                 <li><a href="http://139968.aceboard.fr/139968-866-0-Site-VirtuAiles.htm">Le Site VirtuAiles</a></li>
  99.                 <li><a href="http://139968.aceboard.fr/139968-1434-0-Questions-Techniques.htm">Questions Techniques</a></li>
  100.                 <li><a href="http://139968.aceboard.fr/139968-864-0-Media-Photos-Video.htm">Média/Photos/Vidéo</a></li>
  101.                 <li><a href="http://139968.aceboard.fr/139968-1444-0-connais-veux-vous-dire.htm">Je connais... et je veux vous dire</a></li>
  102.                 <li><a href="http://139968.aceboard.fr/139968-1435-0-Questions-Generales.htm">Questions Générales</a></li>
  103.                 <li><a href="http://139968.aceboard.fr/139968-1283-0-Liens-proposer.htm">Liens à proposer</a></li>
  104.                 <li><a href="http://139968.aceboard.fr/139968-1457-0-Debats.htm">Débats</a></li>
  105.                 <li><a href="http://139968.aceboard.fr/139968-1871-0-Reserve-Inscrits.htm">Réservé aux Inscrits</a></li>
  106.           </ul>
  107.     </li>
  108.         <li>
  109.           <a href="#">Dossiers</a>
  110.           <ul>
  111.               <li><a href="http://virtuailes.iquebec.com/avro_arrow_introduction.php">L'Avro CF-105 Arrow</a></li>
  112.                 <li><a href="http://virtuailes.iquebec.com/f35.php">Le F/A-35 JSF</a></li>
  113.                 <li><a href="http://virtuailes.iquebec.com/sr71family.php">La famille Blackbird</a></li>
  114.                 <li><a href="http://virtuailes.iquebec.com/constr.php">Le DHC-2 Beaver</a></li>
  115.                 <li><a href="http://virtuailes.iquebec.com/constr.php">Le BA CSeries</a></li>
  116.                 <li><a href="http://virtuailes.iquebec.com/constr.php">Le Convair B-58 Hustler</a></li>
  117.           </ul>
  118.     </li>
  119.         <li>
  120.           <a href="#">Téléchargements</a>
  121.           <ul>
  122.               <li><a href="http://virtuailes.iquebec.com/telechargements_videos.php">Vidéos</a></li>
  123.                 <li><a href="http://virtuailes.iquebec.com/telechargements_diaporammas.php">Diaporamas</a></li>
  124.                 <li><a href="http://virtuailes.iquebec.com/telechargements_photos.php">Photos</a></li>
  125.                 <li><a href="http://virtuailes.iquebec.com/telechargements_documents.php">Documents</a></li>
  126.                 <li><a href="http://virtuailes.iquebec.com/telechargements_autres.php">Autres</a></li>
  127.           </ul>
  128.     </li>
  129.         <li>
  130.       </ul>
  131.   <script type="text/javascript">
  132. // <![CDATA[
  133. function loopElements(el,level){
  134.     for(var i=0;i<el.childNodes.length;i++){
  135.         //We only want LI nodes:
  136.         if(el.childNodes[i] && el.childNodes[i]["tagName"] && el.childNodes[i].tagName.toLowerCase() == "li" ){
  137.             //Ok we have the LI node - let's give it a className
  138.             el.childNodes[i].className = "myMenu"+level
  139.             //Let's look for the A and if it has child elements (another UL tag)
  140.             childs = el.childNodes[i].childNodes
  141.             for(var j=0;j<childs.length;j++){
  142.                 temp = childs[j]
  143.                 if(temp && temp["tagName"]){
  144.                     if(temp.tagName.toLowerCase() == "a" ){
  145.                         //We found the A tag - set class
  146.                         temp.className = "myMenu"+level
  147.                         //Adding click event
  148.                         temp.onclick=showHide;
  149.                     }else if(temp.tagName.toLowerCase() == "ul" ){
  150.                         //Hide sublevels
  151.                         temp.style.display = "none"
  152.                         //Set class
  153.                         temp.className= "myMenu"+level
  154.                         //Recursive - calling it self with the new found element
  155.                         //to go all the way through the three.
  156.                         loopElements(temp,level +1)
  157.                     }
  158.                 }
  159.             }
  160.         }
  161.     }
  162. }
  163. var menu = document.getElementById("myMenu" ) //Get menu div
  164. menu.className="myMenu"+0 //Set class to the top level
  165. loopElements(menu,0) //Call the function
  166. function showHide(){
  167.     //We have a A tag - need to go to the LI tag to check for UL tags:
  168.     el = this.parentNode
  169.     //Loop for UL tags:
  170.     for(var i=0;i<el.childNodes.length;i++){
  171.         temp = el.childNodes[i]
  172.         if(temp && temp["tagName"] && temp.tagName.toLowerCase() == "ul" ){
  173.             //Check status:
  174.             if(temp.style.display=="none" ){
  175.                 temp.style.display = ""
  176.             }else{
  177.                 temp.style.display = "none"
  178.             }
  179.         }
  180.     }
  181.     return false
  182. }
  183. // ]]>
  184. </script>



Merci de votre aide!

VirtuAiles

Liens sponsorisés


Inscrivez-vous ou connectez-vous pour masquer ceci.

Profil : IDNaute
Plus d'informations

Note: J'ai totalement changé mon message après quelques modifications.

Profil : IDNaute
Plus d'informations

De plus, les liens sont faits mais il ne se passe rien lorsqu'on clique dessus.

Merci!

Profil : IDNaute
Plus d'informations

:confused:

Profil : IDNaute
Plus d'informations

pour le mettre à gauche :

Code :
  1. #myMenu{
  2.     position:absolute;
  3.     top:0;
  4.     left:0;
  5.     width:20%;
  6. }


Aller à :
 
  FORUM Infos-du-Net » Programmation » Menu déroulant

Liens