aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-11-10 03:51:59 +0100
committerpolo <ordipolo@gmx.fr>2025-11-10 03:51:59 +0100
commit854bde3095c195a3c628be878fc776e16f4bd424 (patch)
tree6a61267d84fa4ba7ddf48240cd0249390e349742
parent63c37a85fc59bd8183ba22c9a87268df9cda25be (diff)
downloadcms-854bde3095c195a3c628be878fc776e16f4bd424.tar.gz
cms-854bde3095c195a3c628be878fc776e16f4bd424.tar.bz2
cms-854bde3095c195a3c628be878fc776e16f4bd424.zip
menu responsive !!
-rw-r--r--public/css/head.css22
-rw-r--r--public/css/nav.css184
-rw-r--r--public/js/main.js16
-rw-r--r--src/view/templates/header.php8
4 files changed, 145 insertions, 85 deletions
diff --git a/public/css/head.css b/public/css/head.css
index 1b805fe..4df68ba 100644
--- a/public/css/head.css
+++ b/public/css/head.css
@@ -1,38 +1,28 @@
1header 1header
2{ 2{
3 text-align: center; 3 text-align: center;
4 /*padding-top: 5px;*/
5 /*padding-bottom: 10px;*/
6 background-size: cover; /* largeur du bloc_page */ 4 background-size: cover; /* largeur du bloc_page */
7 background-position: center; 5 background-position: center;
8} 6}
9#nav_zone
10{
11 /*margin: auto;*/
12 /*max-width: 1200px;*/
13 display: flex;
14 /*align-items: center;*/ /* conflit possible avec .social align-self */
15 justify-content: center;
16}
17.nav_button{
18 display: none;
19}
20 7
21.background_button 8.background_button
22{ 9{
23 max-height: 24px; 10 max-height: 24px;
24} 11}
25.header_additional_inputs 12.header_above
26{ 13{
27 display: flex; 14 display: flex;
28 flex-wrap: wrap; 15 flex-wrap: wrap;
29 justify-content: space-evenly; 16 justify-content: space-evenly;
30 align-items: center; 17 align-items: center;
31 margin-top: 10px; 18}
19.header_above > div > *
20{
21 margin: 10px 0;
32} 22}
33.header_content 23.header_content
34{ 24{
35 margin-top: 10px; 25 /*margin-top: 10px;*/
36 padding-bottom: 20px; 26 padding-bottom: 20px;
37 display: grid; 27 display: grid;
38 grid-template-columns: 1fr 1fr 1fr; 28 grid-template-columns: 1fr 1fr 1fr;
diff --git a/public/css/nav.css b/public/css/nav.css
index 72aaf4b..165af71 100644
--- a/public/css/nav.css
+++ b/public/css/nav.css
@@ -1,45 +1,145 @@
1/*-- menu principal --*/ 1/*-- menu principal --*/
2#nav_zone 2
3{ 3/* version horizontale */
4 /*height: 33px;*/ 4@media screen and (min-width: 601px){
5 /*width: 100%;*/ 5 .nav_button{
6 display: none;
7 }
8 #nav_zone
9 {
10 /*margin: auto;*/
11 /*max-width: 1200px;*/
12 display: flex;
13 /*align-items: center;*/ /* conflit possible avec .social align-self */
14 justify-content: center;
15 }
16 .nav_main{
17 display: block;
18 background-color: #ffffffe1; /* b3 = 179 = 0.7 (x 256) */
19 text-align: center;
20 position: fixed;
21 }
22 .nav_main > ul{
23 display: flex;
24 justify-content: center;
25 flex-wrap: wrap;
26 }
27 .nav_main ul{
28 padding-left: 0;
29 }
30 .nav_main li{
31 padding: 5px;
32 }
33 .sub-menu{
34 border-top: 3px solid #13aff0;
35 }
36 /* élément du menu survolé, le positionnement relatif en fait la référence du positionnement suivant */
37 .drop-right .sub-menu
38 {
39 position: absolute; /* positionnement par rapport au précédent "position" en CSS */
40 left: 100%;
41 top: -3px; /* la bordure bleue fait 3px */
42 }
43 /* 1er sous-menu, poitionnement pour ne pas aggrandir l'élément parent */
44 nav > ul > li > ul
45 {
46 position: absolute; /* retire du flux, positionnement par rapport à la fenêtre */
47 margin-top: 5px;
48 margin-left: -5px;
49 }
50
51 @media (pointer: fine){
52 .nav_main > ul > li:hover
53 {
54 background-color: white;
55 }
56 .drop-right > a > p:after{
57 content: " ▶";
58 }
59 }
60}
61
62@media screen and (min-width: 1000px){
63 nav > ul > li > ul{
64 margin-left: -7px; /* annuler le déplacement dû au padding: 7px; dans ".nav_main li" */
65 margin-top: 7px;
66 }
67 .nav_main li{
68 padding: 7px;
69 }
70}
71
72/* version petits écrans */
73@media screen and (max-width: 600px){
74 #nav_zone{
75 padding-top: 5px;
76 }
77 .nav_button{
78 display: block;
79 }
80 .nav_main{
81 display: none;
82 margin: 10px;
83 background-color: white;
84 text-align: left;
85 }
86 .nav_main.show{
87 display: block;
88 }
89 /*.nav_main > ul{}*/
90 .nav_main li{
91 padding: 5px;
92 }
93 .drop-down{
94 width: min-content;
95 }
96 .sub-menu{
97 margin-top: 5px;
98 }
99 .nav_main ul{
100 padding-left: 20px;
101 padding-right: 20px;
102 }
103
104 /*nav > ul > li > ul{
105 margin-left: 0;
106 }*/
107 @media (pointer: fine){
108 .nav_main li > a:hover{
109 background-color: yellow;
110 }
111 .drop-right > a > p:after{
112 content: ' ▼';
113 }
114 }
6} 115}
116
117
7.nav_main 118.nav_main
8{ 119{
9 position: fixed; 120 /*position: fixed;*/
10 /*box-shadow: 3px 3px 5px #13aff0;*/
11 border: 2px solid #13aff0; 121 border: 2px solid #13aff0;
12 top: -2px; 122 top: -2px;
13}
14.nav_main
15{
16 /*font-size: 90%;*/ 123 /*font-size: 90%;*/
17 /*margin-top: 10px;*/
18 /*margin-bottom: 10px;*/
19 text-wrap: nowrap; 124 text-wrap: nowrap;
20 background-color: #ffffffe1; /* b3 = 179 = 0.7 (x 256) */ 125 /*max-width: 90%;*/
21} 126}
22.nav_main > ul 127.sub-menu{
23{ 128 box-shadow: 1px 1px 3px black;
24 display: flex;
25 flex-direction: row;
26 justify-content: center;
27 flex-wrap: wrap;
28} 129}
29ul 130ul{
30{
31 margin: 0; 131 margin: 0;
32} 132}
33 133
34.nav_main ul 134.nav_main ul
35{ 135{
36 list-style: none; 136 /*list-style: none;*/
37 padding-left: 0; 137 /*padding-left: 0;*/
38} 138}
39.nav_main li 139.nav_main li
40{ 140{
41 list-style: none; 141 list-style: none;
42 padding: 7px; 142
43} 143}
44.nav_main p 144.nav_main p
45{ 145{
@@ -59,14 +159,11 @@ li:not(.current){
59} 159}
60 160
61 161
162
62/* sous-menus avec PC + souris 163/* sous-menus avec PC + souris
63mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :hover, cassant le JS utilisé ici */ 164mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :hover, cassant le JS utilisé ici */
64@media (pointer: fine) /* fine => précision de la souris */ 165@media (pointer: fine) /* fine => précision de la souris */
65{ 166{
66 .nav_main > ul > li:hover
67 {
68 background-color: white;
69 }
70 .drop-down:hover > .sub-menu, 167 .drop-down:hover > .sub-menu,
71 .drop-right:hover > .sub-menu 168 .drop-right:hover > .sub-menu
72 { 169 {
@@ -84,7 +181,6 @@ mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :h
84 } 181 }
85 .drop-right > a > p:after 182 .drop-right > a > p:after
86 { 183 {
87 content: " ▶";
88 font-size: x-small; 184 font-size: x-small;
89 } 185 }
90} 186}
@@ -113,46 +209,19 @@ mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :h
113 display: block; 209 display: block;
114 } 210 }
115} 211}
116
117
118.sub-menu 212.sub-menu
119{ 213{
120 display: none; 214 display: none;
121 background-color: white; 215 background-color: white;
122 border-top: 3px solid #13aff0;
123 box-shadow: 1px 1px 3px black;
124 font-size: 95%; 216 font-size: 95%;
125} 217}
126 218
127
128/* 1er sous-menu, poitionnement pour ne pas aggrandir l'élément parent */
129nav > ul > li > ul
130{
131 position: absolute; /* retire du flux, positionnement par rapport à la fenêtre */
132 margin-left: -7px; /* annuler le déplacement dû au padding: 7px; dans ".nav_main li" */
133 margin-top: 7px;
134}
135/* élément du menu survolé, le positionnement relatif en fait la référence du positionnement suivant */
136.drop-right
137{
138 /*position: relative;*/
139}
140.drop-right .sub-menu
141{
142 position: absolute; /* positionnement par rapport au précédent "position" en CSS */
143 left: 100%;
144 top: -3px; /* la bordure bleue fait 3px */
145}
146
147@media screen and (max-width: 1000px){ 219@media screen and (max-width: 1000px){
148 #nav_zone 220 #nav_zone
149 { 221 {
150 /*height: 29px;*/ 222 /*height: 29px;*/
151 } 223 }
152 .nav_main li 224
153 {
154 padding: 5px;
155 }
156 .nav_main p 225 .nav_main p
157 { 226 {
158 /*font-size: smaller;*/ 227 /*font-size: smaller;*/
@@ -160,8 +229,7 @@ nav > ul > li > ul
160 } 229 }
161 nav > ul > li > ul 230 nav > ul > li > ul
162 { 231 {
163 margin-left: -5px; 232 /*margin-top: 5px;*/
164 margin-top: 5px;
165 } 233 }
166} 234}
167@media screen and (max-width: 450px){ 235@media screen and (max-width: 450px){
diff --git a/public/js/main.js b/public/js/main.js
index 5bab6ed..fa02ddb 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -50,7 +50,7 @@ function controlURL(input){
50 50
51// exécuté à la fin du chargement de la page 51// exécuté à la fin du chargement de la page
52document.addEventListener('DOMContentLoaded', () => { 52document.addEventListener('DOMContentLoaded', () => {
53 53 navHeight(); // hauteur de <nav> en fonction de celle du menu en position fixe
54 insertLocalDates(); 54 insertLocalDates();
55 55
56 // ouvrir/fermer les sous-menus avec écran tactile 56 // ouvrir/fermer les sous-menus avec écran tactile
@@ -77,20 +77,22 @@ document.addEventListener('DOMContentLoaded', () => {
77 } 77 }
78 }); 78 });
79 }); 79 });
80});
80 81
81 // hauteur de <nav> en fonction de celle du menu en position fixe 82function navHeight(){
82 const nav = document.querySelector('nav'); 83 const nav = document.querySelector('nav'); // détection
83 const nav_zone = document.getElementById('nav_zone'); 84 const nav_zone = document.getElementById('nav_zone');
84 const resize_observer = new ResizeObserver(entries => { 85 const resize_observer = new ResizeObserver(entries => { // param de type tableau
86 let nav_button_height = window.innerWidth <= 600 ? 26 : 0; // 26 = taille du bouton
87 nav_button_height += nav.classList.contains('show') ? 15 : 0;
85 for(const entry of entries){ 88 for(const entry of entries){
86 nav_zone.style.height = entry.contentRect.height + 'px'; 89 nav_zone.style.height = (entry.contentRect.height + nav_button_height) + 'px';
87 } 90 }
88 }); 91 });
89 if(nav){ 92 if(nav){
90 resize_observer.observe(nav); 93 resize_observer.observe(nav);
91 } 94 }
92}); 95}
93
94 96
95function fetchArticles(bloc_id){ 97function fetchArticles(bloc_id){
96 const parent = document.getElementById(bloc_id); 98 const parent = document.getElementById(bloc_id);
diff --git a/src/view/templates/header.php b/src/view/templates/header.php
index ba17dcd..9d2f071 100644
--- a/src/view/templates/header.php
+++ b/src/view/templates/header.php
@@ -3,9 +3,12 @@
3 <div> 3 <div>
4 <header style="background-image: url('<?= $header_background ?? '' ?>');"> 4 <header style="background-image: url('<?= $header_background ?? '' ?>');">
5 <div id="nav_zone"> 5 <div id="nav_zone">
6 <div class="nav_button">
7 <button onclick="document.getElementById('nav_zone').querySelector('.nav_main').classList.toggle('show');">MENU</button>
8 </div>
6 <?= $nav ?> 9 <?= $nav ?>
7 </div> 10 </div>
8 <div class="header_additional_inputs"> 11 <div class="header_above">
9 <div id="head_favicon"> 12 <div id="head_favicon">
10 <?= $admin_head_favicon ?> 13 <?= $admin_head_favicon ?>
11 </div> 14 </div>
@@ -20,9 +23,6 @@
20 <?= $admin_header_logo ?> 23 <?= $admin_header_logo ?>
21 </div> 24 </div>
22 </div> 25 </div>
23 <div class="nav_button">
24 <button>MENU</button>
25 </div>
26 <div class="header_center_col"> 26 <div class="header_center_col">
27 <h1 id="header_title"> 27 <h1 id="header_title">
28 <a id="header_title_content" href="<?= new URL ?>"><?= htmlspecialchars($title ?? '') ?></a> 28 <a id="header_title_content" href="<?= new URL ?>"><?= htmlspecialchars($title ?? '') ?></a>