CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

[HELP] Problème menu déroulant HTML/CSS/Javascript

Epidemio
Epidemio
Niveau 1
15 mars 2021 à 17:08:58

Bonjour à tous,

je suis en train de créer un petit site web tout simple et j'ai un problème avec mon menu déroulant qui est censé pouvoir faire défiler des lettres mais quand on scrolle tout le bloc descend avec (désolé si c'est mal expliqué je vous met le lien du site pour que vous puissiez visualiser :) )

Voici le lien du site: https://projet-nsi.go.yj.fr/page%202.html

Ainsi que le code HTML:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="style.css" /> <title>iMusic</title> </head> <body> <header> <img src="logo.png" height="160px"> </header> <div id="mySidenav" class="sidenav"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a> <nav> <ul> <li class="deroulant"><a href="#">Liste Alphabétique &ensp;</a> <ul class="sous"> <li><a href="A.html">A</a></li> <li><a href="B.html">B</a></li> <li><a href="C.html">C</a></li> <li><a href="D.html">D</a></li> <li><a href="E.html">E</a></li> <li><a href="F.html">F</a></li> <li><a href="#">G</a></li> <li><a href="#">H</a></li> <li><a href="#">I</a></li> <li><a href="#">J</a></li> <li><a href="#">K</a></li> <li><a href="#">L</a></li> <li><a href="#">M</a></li> <li><a href="#">N</a></li> <li><a href="#">O</a></li> <li><a href="#">P</a></li> <li><a href="#">Q</a></li> <li><a href="#">R</a></li> <li><a href="#">S</a></li> <li><a href="#">T</a></li> <li><a href="#">U</a></li> <li><a href="#">V</a></li> <li><a href="#">W</a></li> <li><a href="#">X</a></li> <li><a href="#">Y</a></li> <li><a href="#">Z</a></li> </ul> </li> </ul> </nav> </div> <div id="main"> <span style="color: rgb(25, 20, 20);font-size:30px;cursor:pointer" onclick="openNav()">&#9776; Menu</span> </div> <script> function openNav() { document.getElementById("mySidenav").style.width = "250px"; document.getElementById("main").style.marginLeft = "250px"; } function closeNav() { document.getElementById("mySidenav").style.width = "0"; document.getElementById("main").style.marginLeft= "0"; } </script> </body> </html>

Et le code CSS: html{ background-color: #B4F8FA; font-family: Verdana,Arial; } body{ margin: 0; padding: 0; } .bouton{ color: #B4F8FA; font-size: 17px; cursor: pointer; margin: 250px; padding: 5px; background-color: rgb(25, 20, 20); border-radius: 10px; width: 200px; margin-top: center; display: block; margin-left: auto; margin-right: auto; border: 10px rgb(25, 20, 20) outset; box-shadow: 6px 6px 6px #65B1B3; -webkit-user-select: none; user-select: none; -moz-user-select: none; font-family: Arial Black; border-bottom: 5px; } .bouton:hover { color:#65B1B3; box-shadow: none; } header{ background-color: rgb(25, 20, 20); height: 40px; width: 100%; margin: 0; padding: 10px; color: rgb(30, 215, 96); text-align: center; vertical-align: middle; font-size: 25px; display: table; font-family: Arial Black; } .sidenav{ height: 100%; width: 160px; position: fixed; z-index: 1; top: 0; left: 0; background-color: rgb(25, 20, 20); overflow-x: hidden; padding-top: 20px; } /* The side navigation menu */ .sidenav { height: 100%; /* 100% Full-height */ width: 0; /* 0 width - change this with JavaScript */ position: fixed; /* Stay in place */ z-index: 1; /* Stay on top */ top: 0; /* Stay at the top */ left: 0; background-color:rgb(25,20,20); /* Black*/ overflow-x: hidden; /* Disable horizontal scroll */ padding-top: 60px; /* Place content 60px from the top */ transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */ } /* The navigation menu links */ .sidenav a { padding: 8px 8px 8px 32px; text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s; } /* When you mouse over the navigation links, change their color */ .sidenav a:hover { color: #B4F8FA; } /* Position and style the close button (top right corner) */ .sidenav .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; margin-left: 50px; } /* Style page content - use this if you want to push the page content to the right when you open the side navigation */ #main { transition: margin-left .5s; padding: 20px; } /* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */ @media screen and (max-height: 450px) { .sidenav {padding-top: 15px;} .sidenav a {font-size: 18px;} } *{ margin: 0px; padding: 0px; font-family: Avenir, sans-serif; } nav{ width: 100%; margin: 0 auto; background-color:rgb(25,20,20); position: sticky; top: 0px; } nav ul{ list-style-type: none; } nav ul li{ float: left; width: 25%; text-align: center; position: relative; } nav ul::after{ content: ""; display: table; clear: both; } nav a{ display: block; text-decoration: none; color: black; border-bottom: 2px solid transparent; padding: 10px 0px; } nav a:hover{ color: #B4F8FA; border-bottom: 2px solid #B4F8FA; } .sous{ display: none; box-shadow: 0px 1px 2px #CCC; background-color: rgb(25,20,20); position: absolute; width: 100%; z-index: 1000; } nav > ul li:hover .sous{ display: block; } .sous li{ float: none; width: 100%; text-align: left; } .sous a{ padding: 10px; border-bottom: none; } .sous a:hover{ border-bottom: none; background-color: RGBa(200,200,200,0.1); } .deroulant > a::after{ font-size: 15px; bottom: 30px; } .conteneur{ margin: 50px 20px; height: 1500px; }

Merci beaucoup d'avance pour votre aide ! :-)))

LREM_officiel
LREM_officiel
Niveau 9
24 mars 2021 à 17:31:03

je ne sais pas comment t'aider mais j'aime beaucoup ton site :oui:

:up:

SoRoughh
SoRoughh
Niveau 26
24 mars 2021 à 23:56:11

Je peux te donner une piste.

Le scroll est associé à toute ta navigation alors que te toi tu veux qu'il-y-en ait un uniquement au niveau des lettres

La 1ère étape est de supprimer ce scroll de ta nav en faisant overflow:hidden;

Ensuite, il faut que tu ajoutes overflow:scroll, a ta div qui contient les lettres, cependant pour que ce soit possible, il faut que celle-ci dispose d'une hauteur fixe, sinon impossible de gérer le scroll

SoRoughh
SoRoughh
Niveau 26
25 mars 2021 à 10:46:24

Je reviens sur ce que j'ai dis, c'est pas forcement une hauteur fixe, ça peut etre du % ou autre, mais en tout cas il faut que celle-ci soit definit sinon on ne sait pas à partir de quand on peut scroll

Sous forums
  • Aide à l'achat Mac
  • Création de Jeux
  • Linux
  • Création de sites web
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment