_menu-burger-auto.scss 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* themes/custom/reha/assets/css/menu-burger-auto.css */
  2. .rb-sr {
  3. position:absolute !important; width:1px; height:1px; padding:0; margin:-1px;
  4. overflow:hidden; clip:rect(0,0,0,0); clip-path: inset(50%); white-space:nowrap; border:0;
  5. }
  6. /* Bouton burger */
  7. .rb-toggle {
  8. display:inline-flex; align-items:center; justify-content:center;
  9. gap:.5rem; border:1px solid #ddd; background:#fff; color:#111;
  10. border-radius:.75rem; padding:.6rem .8rem; cursor:pointer;
  11. }
  12. /* Icône */
  13. .rb-burger { display:inline-flex; flex-direction:column; gap:6px; }
  14. .rb-line { width:22px; height:2px; background:currentColor; display:block;
  15. transition: transform .2s ease, opacity .2s ease; }
  16. /* Anim "X" */
  17. .rb-toggle.is-active .rb-line:nth-child(1){ transform: translateY(8px) rotate(45deg); }
  18. .rb-toggle.is-active .rb-line:nth-child(2){ opacity:0; }
  19. .rb-toggle.is-active .rb-line:nth-child(3){ transform: translateY(-8px) rotate(-45deg); }
  20. /* Liste (mobile) */
  21. #main-nav.rb-list {
  22. list-style:none; padding:0; margin:.75rem 0 0 0; display:grid; gap:.25rem;
  23. }
  24. #main-nav.rb-list a {
  25. display:block; padding:.75rem 1rem; border-radius:.5rem; text-decoration:none;
  26. background:#fff; color:#111;
  27. }
  28. #main-nav.rb-list a:focus-visible { outline:2px solid #5b9aff; outline-offset:2px; }
  29. /* Desktop / tablette */
  30. @media (min-width:768px){
  31. .rb-toggle{ display:none; }
  32. #main-nav.rb-list { display:flex; gap:.5rem; margin-top:0; }
  33. #main-nav.rb-list a { background:transparent; padding:.5rem .75rem; }
  34. #main-nav.rb-list a:hover { text-decoration: underline; }
  35. }
  36. /* Impression : menu toujours visible */
  37. @media print {
  38. .rb-toggle{ display:none !important; }
  39. #main-nav.rb-list{ display:block !important; }
  40. }
  41. /* 1) Garantir que l’attribut hidden cache bien l’élément,
  42. même si un autre CSS met un display:... */
  43. #main-nav[hidden] { display: none !important; }
  44. /* 2) Fallback ultra simple : on cache le menu en mobile,
  45. et on l’affiche quand le bouton est actif.
  46. (Le JS insère le bouton juste AVANT le <ul>, donc l’adjacence fonctionne) */
  47. @media (max-width: 767px) {
  48. #main-nav.rb-list { display: none !important; }
  49. .rb-toggle.is-active + #main-nav.rb-list { display: grid !important; }
  50. }
  51. /* --- Empêcher le menu d'impacter la mise en page du header (mobile) --- */
  52. @media (max-width: 767.98px) {
  53. /* Le conteneur nav sert d'ancre pour le positionnement absolu */
  54. #block-reha-navigationprincipale {
  55. position: relative;
  56. overflow: visible; /* au cas où un parent a overflow:hidden */
  57. /* optionnel : si le header a text-align:center et que tu veux
  58. que le bouton reste à gauche, décommente la ligne suivante */
  59. /* text-align: initial; */
  60. }
  61. /* Par défaut, menu masqué quand le bouton n'est pas actif */
  62. #block-reha-navigationprincipale .rb-toggle + #main-nav.rb-list {
  63. display: none !important;
  64. }
  65. /* Quand on ouvre: on montre le menu en position absolue, hors du flux */
  66. #block-reha-navigationprincipale .rb-toggle.is-active + #main-nav.rb-list {
  67. display: grid !important;
  68. }
  69. /* Sortir le UL du flux et de tout align center, en overlay sous la barre */
  70. #block-reha-navigationprincipale #main-nav.rb-list {
  71. position: absolute;
  72. top: 100%; /* juste sous la barre de nav */
  73. left: 0;
  74. right: 0; /* pleine largeur du nav */
  75. z-index: 1000;
  76. text-align: left; /* ignore tout text-align:center parent */
  77. margin: 0;
  78. padding: .5rem;
  79. background: #fff;
  80. box-shadow: 0 8px 20px rgba(0,0,0,.15);
  81. }
  82. #block-reha-navigationprincipale #main-nav.rb-list a {
  83. display: block;
  84. }
  85. }
  86. /* --- Desktop : on remet le menu dans le flux normal --- */
  87. @media (min-width: 768px) {
  88. #block-reha-navigationprincipale #main-nav.rb-list {
  89. position: static;
  90. box-shadow: none;
  91. padding: 0;
  92. }
  93. }