diff options
| author | polo <ordipolo@gmx.fr> | 2025-11-13 12:02:54 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-11-13 12:02:54 +0100 |
| commit | 3fb31866c721ef9cd07eea5151e00c1b154da9ad (patch) | |
| tree | 7204180a603f115008f869476c313a1077f5619f | |
| parent | 854bde3095c195a3c628be878fc776e16f4bd424 (diff) | |
| download | cms-3fb31866c721ef9cd07eea5151e00c1b154da9ad.tar.gz cms-3fb31866c721ef9cd07eea5151e00c1b154da9ad.tar.bz2 cms-3fb31866c721ef9cd07eea5151e00c1b154da9ad.zip | |
bouton et menu fixés sur petit écran
| -rw-r--r-- | public/css/nav.css | 98 | ||||
| -rw-r--r-- | public/js/main.js | 4 |
2 files changed, 39 insertions, 63 deletions
diff --git a/public/css/nav.css b/public/css/nav.css index 165af71..ff31813 100644 --- a/public/css/nav.css +++ b/public/css/nav.css | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | background-color: #ffffffe1; /* b3 = 179 = 0.7 (x 256) */ | 18 | background-color: #ffffffe1; /* b3 = 179 = 0.7 (x 256) */ |
| 19 | text-align: center; | 19 | text-align: center; |
| 20 | position: fixed; | 20 | position: fixed; |
| 21 | top: -2px; | ||
| 21 | } | 22 | } |
| 22 | .nav_main > ul{ | 23 | .nav_main > ul{ |
| 23 | display: flex; | 24 | display: flex; |
| @@ -47,6 +48,14 @@ | |||
| 47 | margin-top: 5px; | 48 | margin-top: 5px; |
| 48 | margin-left: -5px; | 49 | margin-left: -5px; |
| 49 | } | 50 | } |
| 51 | |||
| 52 | @media screen and (max-width: 1000px){ /* entre 601 et 1000 */ | ||
| 53 | .nav_main p | ||
| 54 | { | ||
| 55 | /*font-size: smaller;*/ | ||
| 56 | font-size: 90%; | ||
| 57 | } | ||
| 58 | } | ||
| 50 | 59 | ||
| 51 | @media (pointer: fine){ | 60 | @media (pointer: fine){ |
| 52 | .nav_main > ul > li:hover | 61 | .nav_main > ul > li:hover |
| @@ -58,30 +67,48 @@ | |||
| 58 | } | 67 | } |
| 59 | } | 68 | } |
| 60 | } | 69 | } |
| 70 | @media screen and (max-width: 450px){ | ||
| 71 | .sub-menu p{ | ||
| 72 | font-size: 90%; | ||
| 73 | } | ||
| 74 | } | ||
| 61 | 75 | ||
| 62 | @media screen and (min-width: 1000px){ | 76 | @media screen and (min-width: 1000px){ |
| 63 | nav > ul > li > ul{ | 77 | nav > ul > li > ul{ |
| 64 | margin-left: -7px; /* annuler le déplacement dû au padding: 7px; dans ".nav_main li" */ | 78 | margin-left: -7px; /* annuler le déplacement dû au padding: 7px; dans ".nav_main li" */ |
| 65 | margin-top: 7px; | 79 | margin-top: 7px; |
| 66 | } | 80 | } |
| 67 | .nav_main li{ | 81 | .nav_main li{ |
| 68 | padding: 7px; | 82 | padding: 7px; |
| 69 | } | 83 | } |
| 70 | } | 84 | } |
| 71 | 85 | ||
| 72 | /* version petits écrans */ | 86 | /* version petits écrans */ |
| 73 | @media screen and (max-width: 600px){ | 87 | @media screen and (max-width: 600px){ |
| 74 | #nav_zone{ | 88 | #nav_zone{ |
| 75 | padding-top: 5px; | 89 | /*position: fixed;*/ |
| 90 | display: flex; | ||
| 91 | flex-direction: column; | ||
| 92 | /*margin: 10px;*/ | ||
| 93 | } | ||
| 94 | .nav_button, .nav_main | ||
| 95 | { | ||
| 96 | position: fixed; | ||
| 97 | left: 50%; /* technique pour centrer un élément positionné */ | ||
| 98 | transform: translateX(-50%); | ||
| 76 | } | 99 | } |
| 77 | .nav_button{ | 100 | .nav_button{ |
| 78 | display: block; | 101 | display: block; |
| 102 | margin-top: 5px; | ||
| 103 | position: fixed; | ||
| 79 | } | 104 | } |
| 80 | .nav_main{ | 105 | .nav_main{ |
| 81 | display: none; | 106 | display: none; |
| 82 | margin: 10px; | ||
| 83 | background-color: white; | 107 | background-color: white; |
| 84 | text-align: left; | 108 | text-align: left; |
| 109 | margin: 5px 0; | ||
| 110 | top: 31px; /* = taille bouton et de sa marge */ | ||
| 111 | |||
| 85 | } | 112 | } |
| 86 | .nav_main.show{ | 113 | .nav_main.show{ |
| 87 | display: block; | 114 | display: block; |
| @@ -119,10 +146,9 @@ | |||
| 119 | { | 146 | { |
| 120 | /*position: fixed;*/ | 147 | /*position: fixed;*/ |
| 121 | border: 2px solid #13aff0; | 148 | border: 2px solid #13aff0; |
| 122 | top: -2px; | 149 | /*top: -2px;*/ |
| 123 | /*font-size: 90%;*/ | 150 | /*font-size: 90%;*/ |
| 124 | text-wrap: nowrap; | 151 | text-wrap: nowrap; |
| 125 | /*max-width: 90%;*/ | ||
| 126 | } | 152 | } |
| 127 | .sub-menu{ | 153 | .sub-menu{ |
| 128 | box-shadow: 1px 1px 3px black; | 154 | box-shadow: 1px 1px 3px black; |
| @@ -159,7 +185,6 @@ li:not(.current){ | |||
| 159 | } | 185 | } |
| 160 | 186 | ||
| 161 | 187 | ||
| 162 | |||
| 163 | /* sous-menus avec PC + souris | 188 | /* sous-menus avec PC + souris |
| 164 | mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :hover, cassant le JS utilisé ici */ | 189 | mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :hover, cassant le JS utilisé ici */ |
| 165 | @media (pointer: fine) /* fine => précision de la souris */ | 190 | @media (pointer: fine) /* fine => précision de la souris */ |
| @@ -215,52 +240,3 @@ mettre ici tous les blocs avec :hover, les navigateurs mobiles "simulent" les :h | |||
| 215 | background-color: white; | 240 | background-color: white; |
| 216 | font-size: 95%; | 241 | font-size: 95%; |
| 217 | } | 242 | } |
| 218 | |||
| 219 | @media screen and (max-width: 1000px){ | ||
| 220 | #nav_zone | ||
| 221 | { | ||
| 222 | /*height: 29px;*/ | ||
| 223 | } | ||
| 224 | |||
| 225 | .nav_main p | ||
| 226 | { | ||
| 227 | /*font-size: smaller;*/ | ||
| 228 | font-size: 90%; | ||
| 229 | } | ||
| 230 | nav > ul > li > ul | ||
| 231 | { | ||
| 232 | /*margin-top: 5px;*/ | ||
| 233 | } | ||
| 234 | } | ||
| 235 | @media screen and (max-width: 450px){ | ||
| 236 | .nav_button | ||
| 237 | { | ||
| 238 | /*display: block;*/ | ||
| 239 | } | ||
| 240 | #nav_zone | ||
| 241 | { | ||
| 242 | /*position: fixed; | ||
| 243 | justify-content: left;*/ | ||
| 244 | } | ||
| 245 | .nav_main | ||
| 246 | { | ||
| 247 | /*top: 0px;*/ | ||
| 248 | } | ||
| 249 | .nav_main > ul | ||
| 250 | { | ||
| 251 | /*flex-direction: column;*/ | ||
| 252 | } | ||
| 253 | .nav_main li | ||
| 254 | { | ||
| 255 | /**/ | ||
| 256 | } | ||
| 257 | .sub-menu p | ||
| 258 | { | ||
| 259 | font-size: smaller; | ||
| 260 | } | ||
| 261 | .drop-down > .sub-menu | ||
| 262 | { | ||
| 263 | /*flex-direction: row;*/ | ||
| 264 | /*position: static;*/ | ||
| 265 | } | ||
| 266 | } \ No newline at end of file | ||
diff --git a/public/js/main.js b/public/js/main.js index fa02ddb..28a62ae 100644 --- a/public/js/main.js +++ b/public/js/main.js | |||
| @@ -83,8 +83,8 @@ function navHeight(){ | |||
| 83 | const nav = document.querySelector('nav'); // détection | 83 | const nav = document.querySelector('nav'); // détection |
| 84 | const nav_zone = document.getElementById('nav_zone'); | 84 | const nav_zone = document.getElementById('nav_zone'); |
| 85 | const resize_observer = new ResizeObserver(entries => { // param de type tableau | 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 | 86 | let nav_button_height = window.innerWidth <= 600 ? 26 : 0; // 26 = taille du bouton |
| 87 | nav_button_height += nav.classList.contains('show') ? 15 : 0; | 87 | nav_button_height += nav.classList.contains('show') ? 15 : 0; |
| 88 | for(const entry of entries){ | 88 | for(const entry of entries){ |
| 89 | nav_zone.style.height = (entry.contentRect.height + nav_button_height) + 'px'; | 89 | nav_zone.style.height = (entry.contentRect.height + nav_button_height) + 'px'; |
| 90 | } | 90 | } |
