Bonjour, j'ai un problème avec mon menu déroulant, quand je descend sur ma page web mon menu déroulant reste en haut .
Voici mes lignes de codes :
HTML:
<!DOCTYPE html>
<html>
<head lang="fr">
<title>Début</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
</style>
</head>
<body class="margin">
<h1>Mon menu déroulant à un problème</h1>
<br>
<br>
<div class="topnav center">
<div class="search-container">
<form action="/action_page.php">
<input type="text" class="expand" placeholder="Rechercher.." name="search">
<button class="expand" type="submit"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
<br>
<nav>
<ul>
<li class="menu-deroulant">
<a href="#"><pre>Présentation</pre></a>
<ul class="sous-menu">
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</li>
<li class="menu-deroulant vertical">
<a href="#"><pre>Informatique</pre></a>
<ul class="sous-menu">
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</li>
<li class="menu-deroulant vertical">
<a href="#"><pre>Cloud</pre></a>
<ul class="sous-menu">
<li><a href="#" id="ancre"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</li>
<li class="menu-deroulant vertical">
<a href="#"><pre>Web</pre></a>
<ul class="sous-menu">
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</li>
<li class="menu-deroulant vertical">
<a href="#"><pre>Contact </pre></a>
<ul class="sous-menu">
<li><a href="#" id="ancre"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</li>
</ul>
</nav>
CSS:
body{
padding-left: 150px;
padding-right: 150px;
padding-top: 50px;
}
body{
border-color: red;
border-width: px;
border-style: ;
}
.expand{
font-size:20px;
}
.center{
text-align:center;
}
h3{
font-family:montserra, sans-serrif;
font-size:30px;
}
h4{
font-family:montserra, sans-serrif;
font-size:25px;
}
h1 {
font-family:impact;
font-size:50px;
text-align:center;
}
body {
background-color: rgb(255, 255, 128)
}
:root{
--hauteur-menu: 60px;
}
margin: 0px;
padding: 0px;
font-family: Montserrat, sans-serif;
}
nav {
width: 100%;
font-size: 18px;
position: sticky;
top: 0;
}
nav > ul {
display: flex;
text-align: center;
box-shadow: 0px 1px 2px 1px rgba(0,0,0,0.3);
height: var(--hauteur-menu);
}
nav ul {
list-style-type: none;
}
nav > ul > li {
background-color: white;
position: relative;
height: 100%;
flex: 1;
}
nav > ul > li > a {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
li a {
text-decoration: none;
color: black;
}
.menu-deroulant > a:after{
content: '❯';
font-size: 15px;
margin-left: 7px;
display: inline-block;
}
.sous-menu {
margin-top: var(--hauteur-menu);
width: 100%;
text-align: left;
background-color: white;
border-radius: 2px;
overflow: hidden;
max-height: 0;
}
.sous-menu > li > a {
height: 50px;
padding-left: 20px;
width: 100%;
align-items: center;
display: flex;
}
nav > ul > li:hover > a{
color: #2169EC;
}
.sous-menu > li:hover {
background-color: rgba(33, 105, 236, 0.3);
}
.sous-menu > li:hover > a {
color: white;
}
@keyframes rotationFleche {
0% {
transform: rotate(0deg);
}
100%{
transform: rotate(90deg);
}
}
.menu-deroulant:hover > a:after{
animation: rotationFleche 0.2s linear forwards;
}
@keyframes apparitionSousMenu {
0% {
box-shadow: 0px 3px 3px 1px rgba(0,0,0,0);
border-top: 3px solid #2169EC;
}
30% {
box-shadow: 0px 3px 3px 1px rgba(0,0,0,0.3);
}
100% {
max-height: 50em;
border-top: 3px solid #2169EC;
box-shadow: 0px 3px 3px 1px rgba(0,0,0,0.3);
}
}
.menu-deroulant:hover > .sous-menu {
animation: apparitionSousMenu 1s forwards;
}
.vertical {
border-left: 3px solid black;
height:60px;
:root{
--hauteur-menu: 60px;
}
margin: 0px;
padding: 0px;
font-family: Montserrat, sans-serif;
}
nav {
width: 100%;
font-size: 18px;
position: sticky;
top: 0;
}
nav > ul {
display: flex;
text-align: center;
box-shadow: 0px 1px 2px 1px rgba(0,0,0,0.3);
height: var(--hauteur-menu);
}
nav ul {
list-style-type: none;
}
nav > ul > li {
background-color: white;
position: relative;
height: 100%;
flex: 1;
}
nav > ul > li > a {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
li a {
text-decoration: none;
color: black;
}
.menu-deroulant > a:after{
content: '❯';
font-size: 15px;
margin-left: 7px;
display: inline-block;
}
.sous-menu {
margin-top: var(--hauteur-menu);
width: 100%;
text-align: left;
background-color: white;
border-radius: 2px;
overflow: hidden;
max-height: 0;
}
.sous-menu > li > a {
height: 50px;
padding-left: 20px;
width: 100%;
align-items: center;
display: flex;
}
nav > ul > li:hover > a{
color: #2169EC;
}
.sous-menu > li:hover {
background-color: rgba(33, 105, 236, 0.3);
}
.sous-menu > li:hover > a {
color: white;
}
@keyframes rotationFleche {
0% {
transform: rotate(0deg);
}
100%{
transform: rotate(90deg);
}
}
.menu-deroulant:hover > a:after{
animation: rotationFleche 0.2s linear forwards;
}
@keyframes apparitionSousMenu {
0% {
box-shadow: 0px 3px 3px 1px rgba(0,0,0,0);
border-top: 3px solid #2169EC;
}
30% {
box-shadow: 0px 3px 3px 1px rgba(0,0,0,0.3);
}
100% {
max-height: 50em;
border-top: 3px solid #2169EC;
box-shadow: 0px 3px 3px 1px rgba(0,0,0,0.3);
}
}
.menu-deroulant:hover > .sous-menu {
animation: apparitionSousMenu 1s forwards;
}
.vertical {
border-left: 3px solid black;
height:60px;
{box-sizing: border-box;}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #e9e9e9;
}
.topnav a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
background-color: #2196F3;
color: white;
}
.topnav .search-container {
float: right;
}
.topnav input[type=text] {
padding: 6px;
margin-top: 8px;
font-size: 17px;
border: none;
}
.topnav .search-container button {
float: right;
padding: 6px 10px;
margin-top: 8px;
margin-right: 16px;
background: #ddd;
font-size: 17px;
border: none;
cursor: pointer;
}
.topnav .search-container button:hover {
background: #ccc;
}
@media screen and (max-width: 600px) {
.topnav .search-container {
float: none;
}
.topnav a, .topnav input[type=text], .topnav .search-container button {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
Afficher la suite
12 févr. 2022 à 16:24