Bonjour à tous,
J'ai adapté un menu CSS pour un site WEB, mais j'aimerais y ajouter un sous-menu pour un certain item. Je ne sais pas par où commencer exactement.
Votre aide serait grandement apprécié. C'est au niveau du lien Informations que j'aimerais y ajouter 2-3 items en sous-menu.
Je sais qu'il est possible de le faire seulement en HTML et CSS, mais aussi possible d'y ajouter du JavaScript.
Voici le CODE HTML du MENU :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 <nav class="navbar"> <div class="navbar-container"> <input type="checkbox" name="" id=""> <div class="hamburger-lines"> <span class="line line1"></span> <span class="line line2"></span> <span class="line line3"></span> </div> <ul class="menu-items"> <li><a href="#">Accueil</a></li> <li><a href="#">Informations</a></li> <li><a href="#">Nous joindre</a></li> </ul> <img src="images/logo-min.png" class="logo" alt="LOGO"> </div> </nav>
La partie CSS pour le navigateur
Le code CSS Mobile
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 /* NAVBAR - DESKTOP MODE */ .navbar input[type="checkbox"], .navbar .hamburger-lines { display: none; } .navbar { box-shadow: 0px 5px 10px 0px #aaa; position: fixed; top: 0px; width: 100%; background: #000; color: red; opacity: 0.85; height: 90px; z-index: 12; } .navbar-container { display: flex; justify-content: space-between; align-items: center; height: 90px; } .menu-items { order: 2; display: flex; flex-flow: row wrap; } .menu-items li { list-style: none; margin-left: 1rem; margin-right: 1rem; margin-bottom: 0.5rem; font-size: 1rem; } .menu-items a:link, .menu-items a:visited { text-decoration: none; color: darkgoldenrod; transition: color 0.3s ease-in-out; } .menu-items a:hover, .menu-items a:active { color: palegoldenrod; transition: color 0.3s ease-in-out; } .logo { order: 1; font-size: 2.3rem; margin: 0.2rem; padding-left: 0.5rem; } .logo img { display: block; width: 100%; }
Je crois que tout est là, s'il vous manque des informations, juste à demander et je vais répondre de mon mieux.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 /*** MOBILE NAVIGATION ***/ .navbar { opacity: 0.95; } .navbar-container input[type="checkbox"], .navbar-container .hamburger-lines { display: block; } .navbar-container { display: block; position: relative; height: 90px; } .navbar-container input[type="checkbox"] { position: absolute; display: block; height: 32px; width: 30px; top: 20px; left: 20px; z-index: 5; opacity: 0; } .navbar-container .hamburger-lines { display: block; height: 23px; width: 35px; position: absolute; top: 17px; left: 20px; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; } .navbar-container .hamburger-lines .line { display: block; height: 4px; width: 100%; border-radius: 10px; background: #333; } .navbar-container .hamburger-lines .line1 { transform-origin: 0% 0%; transition: transform 0.4s ease-in-out; } .navbar-container .hamburger-lines .line2 { transition: transform 0.2s ease-in-out; } .navbar-container .hamburger-lines .line3 { transform-origin: 0% 100%; transition: transform 0.4s ease-in-out; } .navbar .menu-items { padding-top: 100px; background: red; height: 100vh; max-width: 250px; transform: translate(-150%); display: flex; flex-direction: column; margin-left: -40px; padding-left: 50px; transition: transform 0.5s ease-in-out; box-shadow: 5px 0px 10px 0px #aaa; } .navbar .menu-items li { margin-bottom: 1.5rem; font-size: 1rem; font-weight: 500; } .navbar .menu-items a:link, .navbar .menu-items a:visited { color: black; } .navbar .menu-items a:hover, .navbar .menu-items a:active { color: white; } .logo { position: absolute; padding: 0; margin: 0.2rem; padding-right: 0.5rem; top: 5px; right: 5px; } .navbar-container input[type="checkbox"]:checked ~ .menu-items { transform: translateX(0); } .navbar-container input[type="checkbox"]:checked ~ .hamburger-lines .line1 { transform: rotate(35deg); } .navbar-container input[type="checkbox"]:checked ~ .hamburger-lines .line2 { transform: scaleY(0); } .navbar-container input[type="checkbox"]:checked ~ .hamburger-lines .line3 { transform: rotate(-35deg); }
Partager