Bonjour à tous et à toutes,
Je viens vous demander un coup de main pour centrer un menu dans ma page.
Je cherche depuis deux jours comment faire mais je n'y arrive pas.
Voici le menu
Voici le css
Code php : 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 <?php $onglets = array(); $rubriques = array(); $sous_onglets = array(); $req_menu_hor = $bdd->prepare("SELECT id, nom_onglet, lien_onglet, rubrique_id, nom_rubrique, num_id_menu, cor_id_rub, nom_s_ong, lien_s_ong ,id_rub_cor, nom_img, lien_img FROM menu LEFT JOIN rubrique_menu ON menu.id = rubrique_menu.num_id_menu LEFT JOIN sous_menu ON rubrique_menu.rubrique_id = sous_menu.cor_id_rub LEFT JOIN image_menu ON rubrique_menu.rubrique_id = image_menu.id_rub_cor WHERE auth_view <= :auth ORDER BY ordre_aff, ordre_rubrique, ordre_s_ong, ordre_aff_img ASC"); $req_menu_hor->bindValue('auth', $level, PDO::PARAM_INT); try { $req_menu_hor->execute(); while ($res_menu_hor = $req_menu_hor->fetch()) { $tab_menu[$res_menu_hor['nom_onglet']][] = $res_menu_hor; } } catch (PDOException $e) { echo 'Error : ' . $e->getMessage(); die(); } $req_menu_hor->closeCursor(); echo'<div class="topnav" id="myTopnav">'; echo'<span class="logo_menu"><a href="'.VARIABLE[0].'/" title="Accueil de votre opticien à Marseille"><img src="'.VARIABLE[0].'/images/logo-opticien-marseille-le-lunetier.png" alt="Logo de votre opticien Le Lunetier à Marseille"/></a></span>'; foreach ($tab_menu as $cle_tab_menu => $res_tab_menu) { if($tab_menu[$cle_tab_menu][0]['nom_rubrique'] != '') { echo'<div class="dropdown"><button class="dropbtn">'.$cle_tab_menu.'<i class="fa fa-caret-down"></i> <span class="triangle"></span></button> <div class="dropdown-content"> <div class="row">'; foreach($res_tab_menu as $cle_rub => $val_rub) { if($rub != $val_rub['nom_rubrique']) { echo'<div class="column"> <span class="rubrique_menu">'.$val_rub['nom_rubrique'].'</span>'; foreach($res_tab_menu as $cle_so => $val_so) { if($val_so['cor_id_rub'] == $val_rub['rubrique_id']) echo'<a href="'.VARIABLE[0].'/'.$val_so['lien_onglet'].'.'.$val_so['lien_s_ong'].'.html">'.$val_so['nom_s_ong'].'</a>'; } if($val_rub['nom_img'] != '') { foreach($res_tab_menu as $cle_img => $val_img) { if($val_img['id_rub_cor'] == $val_rub['rubrique_id']) echo'<a class="image_rub" href="'.$val_img['lien_img'].'" title="'.$val_img['lien_img'].'"><img alt="'.$val_img['lien_img'].'" src="'.VARIABLE[0].'/images/menu/'.$val_img['nom_img'].'"></a>'; } } echo'</div>'; } $rub = $val_rub['nom_rubrique']; } echo'</div> </div> </div>'; } else echo'<a href="'.VARIABLE[0].'/'.$tab_menu[$cle_tab_menu][0]['lien_onglet'].'.html">'.$cle_tab_menu.'</a>'; } echo'<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a> </div>'; ?>
et le petit js même si je ne pense pas que ça vienne de là
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205 .logo_menu_gr {display: block;} .topnav .logo_menu {display: none;} .topnav .icon {display: none;} .topnav { max-width:1600px; overflow: hidden; background-color: #fff; font-family: Arial, Helvetica, sans-serif; border-bottom:2px solid #e7e7e7; margin:0 auto; text-align: center; font-variant: small-caps; border:1px solid black; } .topnav a { float: left; display: block; font-size: 16px; color:#555; text-align: center; padding:20px 16px 0 16px; text-decoration: none; line-height:50px; } .topnav .logo_menu a { float: left; padding:0 16px 0 16px; text-decoration: none; } .topnav .logo_menu a:hover:after { background:none; } .dropdown { float: left; display: block; overflow: hidden; } .dropdown .dropbtn { font-size: 16px; border: none; outline: none; color:#555; padding:20px 16px 0 16px; font: inherit; margin: 0; line-height:50px; background: transparent; transition: width .5s ease, background-color .5s ease; } .topnav a:hover, .dropdown:hover .dropbtn { font-weight:700; } .topnav a:after { content: ''; display: block; margin: auto; height: 2px; width: 0; background: transparent; transition: width .5s ease, background-color .5s ease; } .topnav a:hover:after { width:100%; background: #000; } .dropdown .dropbtn:after { content: ''; display: block; margin: auto; height: 2px; width: 0; background: transparent; transition: width .5s ease, background-color .5s ease; } .dropdown .dropbtn:hover:after { width:100%; background: #000; } .dropdown-content { display: none; position: absolute; background-color: #fff; width: 100%; left: 0; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown:hover .dropdown-content { display: block; } /* Create three equal columns that floats next to each other */ .column { float: left; width: 33.33%; padding:10px; background-color: #fff; height:auto; } .column a { float: none; color:#555; padding:0 16px; text-decoration: none; display: block; text-align: left; margin:0; line-height:30px; } .column a:hover { background-color: #e7e7e7; } .column a:hover:after { background:none; } .column a.image_rub { max-width: 100%; min-height:100px; vertical-align:middle; -moz-transition: all 0.8s; -webkit-transition: all 0.8s; transition: all 0.8s; padding:1% 0; } .column a.image_rub:hover { -moz-transform: scale(1.10); -webkit-transform: scale(1.10); transform: scale(1.10); background-color:transparent; } /* Clear floats after the columns */ .row:after { content: ""; display: table; clear: both; } .rubrique_menu { font-size: 1.5rem; color:#000; } @media screen and (max-width: 768px) { .column { width: 100%; height: auto; } .topnav a:not(:first-child), .dropdown .dropbtn { display: none; } .topnav a.icon { float: right; display: block; } .topnav .logo_menu a { float: left; padding:0 16px 0 16px; text-decoration: none; } .topnav .logo_menu a:hover:after { background:none; } .logo_menu_gr {display: none;} .topnav .logo_menu {display: block;} .topnav a:hover:after { background:none; } .topnav.responsive {position: relative;} .topnav.responsive .icon { position: absolute; right: 0; top: 0; } .topnav.responsive a { float: none; display: block; text-align: left; } .topnav.responsive .dropdown {float: none;} .topnav.responsive .dropdown-content {position: relative;} .topnav.responsive .dropdown .dropbtn { display:block; width:100%; text-align:left; vertical-align:top; } .topnav.responsive .dropdown .dropbtn a { display:inline-block; } .triangle { width:0px; height:0px; display:inline-block; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 0; border-bottom: 10px solid #555; } .dropdown:hover .triangle { width:0px; height:0px; display:inline-block; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 0; border-top: 10px solid #000; } }
Code JavaScript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 function myFunction() { var x = document.getElementById("myTopnav"); if (x.className === "topnav") { x.className += " responsive"; } else { x.className = "topnav"; } }
Merci d'avance pour votre aide.
Partager