hamburger.css 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. :root{
  2. --hamburger-size: 20px;
  3. --hamburger-padding: 10px;
  4. --hamburger-margin: 10px;
  5. --hamburger-bgcolor: rgba(0, 0, 0, .1);
  6. }
  7. /* Basic styles */
  8. #mobile-header {
  9. display: -webkit-box;
  10. display: -ms-flexbox;
  11. display: flex;
  12. -webkit-box-align: start;
  13. -ms-flex-align: start;
  14. align-items: flex-start;
  15. -webkit-box-orient: horizontal;
  16. -webkit-box-direction: reverse;
  17. -ms-flex-direction: row-reverse;
  18. flex-direction: row-reverse;
  19. right: 0;
  20. position: relative;
  21. margin: var(--tile-margin) var(--tile-margin) 0 var(--tile-margin);
  22. }
  23. /* Toggle functionality */
  24. #toggle {
  25. position: absolute;
  26. left: -100%;
  27. top: -100%;
  28. }
  29. #toggle:focus ~ .toggle-container .button-toggle,
  30. #toggle:checked ~ .toggle-container .button-toggle {
  31. -webkit-box-shadow: 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor);
  32. box-shadow: 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor);
  33. }
  34. #toggle:checked ~ .toggle-container .button-toggle:hover,
  35. #toggle:checked:focus ~ .toggle-container .button-toggle {
  36. -webkit-box-shadow: 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor);
  37. box-shadow: 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor);
  38. }
  39. #toggle:checked ~ .toggle-container .button-toggle::before {
  40. -webkit-transform: rotate(45deg) scale(1);
  41. transform: rotate(45deg) scale(1);
  42. }
  43. #toggle:checked ~ .toggle-container .button-toggle::after {
  44. -webkit-transform: rotate(-45deg) scale(1);
  45. transform: rotate(-45deg) scale(1);
  46. }
  47. #toggle:checked ~ .nav {
  48. margin-top: 0;
  49. margin-bottom: calc(var(--hamburger-size) + 2*var(--hamburger-padding) + 3*var(--hamburger-margin));
  50. width: 25%;
  51. pointer-events: auto;
  52. -webkit-transform: translate(calc(var(--hamburger-padding) + var(--hamburger-size)), calc(var(--hamburger-size) + 2*(var(--hamburger-padding) + var(--hamburger-margin))));
  53. transform: translate(calc(var(--hamburger-padding) + var(--hamburger-size)), calc(var(--hamburger-size) + 2*(var(--hamburger-padding) + var(--hamburger-margin))));
  54. }
  55. #toggle:checked ~ .nav .nav-item,
  56. #toggle:checked ~ .nav .nav-subitem {
  57. font-family: 'akrobat-regular';
  58. color: black;
  59. width: auto;
  60. height: 2.5em;
  61. line-height: 3em;
  62. text-align: right;
  63. margin: 0;
  64. opacity: 1;
  65. -webkit-transform: scaleY(1);
  66. transform: scaleY(1);
  67. -webkit-transition: .5s, opacity .1s;
  68. transition: .5s, opacity .1s;
  69. }
  70. #toggle:checked ~ .nav .nav-item:nth-child(1),
  71. #toggle:checked ~ .nav .nav-item:nth-child(1)::before {
  72. -webkit-transition-delay: .15s;
  73. transition-delay: .15s;
  74. }
  75. #toggle:checked ~ .nav .nav-subitem,
  76. #toggle:checked ~ .nav .nav-subitem::before {
  77. -webkit-transition-delay: .01s;
  78. transition-delay: .01s;
  79. right: 1em;
  80. }
  81. #toggle:checked ~ .nav .nav-item:nth-child(3),
  82. #toggle:checked ~ .nav .nav-item:nth-child(3)::before {
  83. -webkit-transition-delay: .05s;
  84. transition-delay: .05s;
  85. }
  86. #toggle:checked ~ .nav .nav-item:nth-child(4),
  87. #toggle:checked ~ .nav .nav-item:nth-child(4)::before {
  88. -webkit-transition-delay: 0s;
  89. transition-delay: 0s;
  90. }
  91. #toggle:checked ~ .nav .nav-item::before,
  92. #toggle:checked ~ .nav .nav-subitem::before {
  93. opacity: 0;
  94. }
  95. /* Toggle button */
  96. .button-toggle {
  97. position: relative;
  98. display: inline-block;
  99. right: 0;
  100. width: var(--hamburger-size);
  101. height: var(--hamburger-size);
  102. margin: calc(var(--hamburger-margin) + var(--hamburger-padding)) var(--hamburger-padding);
  103. -webkit-box-shadow: 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor);
  104. box-shadow: 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor), inset 0 0 0 var(--hamburger-padding) var(--hamburger-bgcolor);
  105. border: none;
  106. cursor: pointer;
  107. border-radius: 100%;
  108. -webkit-transition: .6s;
  109. transition: .6s;
  110. }
  111. /* button X container (toggled) */
  112. .button-toggle::before, .button-toggle::after {
  113. position: absolute;
  114. content: '';
  115. top: 50%;
  116. /* left: 0; */
  117. right: 0;
  118. width: 100%;
  119. height: 2px;
  120. background-color: black;
  121. border-radius: 5px;
  122. -webkit-transition: .5s;
  123. transition: .5s;
  124. }
  125. /* button \ container */
  126. .button-toggle::before {
  127. -webkit-transform: rotate(45deg) scale(0);
  128. transform: rotate(45deg) scale(0);
  129. }
  130. /* button / container */
  131. .button-toggle::after {
  132. -webkit-transform: rotate(-45deg) scale(0);
  133. transform: rotate(-45deg) scale(0);
  134. }
  135. /* Menu */
  136. .nav {
  137. display: block;
  138. -webkit-transform: translateX(calc(var(--hamburger-size) + var(--hamburger-padding)));
  139. transform: translateX(calc(var(--hamburger-size) + var(--hamburger-padding)));
  140. margin: calc(var(--hamburger-margin) + var(--hamburger-padding)) 0;
  141. width: var(--hamburger-size);
  142. pointer-events: none;
  143. -webkit-transition: .5s;
  144. transition: .5s;
  145. }
  146. .nav .itemize {
  147. display: -webkit-box;
  148. display: -ms-flexbox;
  149. display: flex;
  150. -webkit-box-align: end;
  151. -ms-flex-align: end;
  152. align-items: flex-end;
  153. -webkit-box-orient: vertical;
  154. -webkit-box-direction: normal;
  155. -ms-flex-direction: column;
  156. flex-direction: column;
  157. padding: 0;
  158. margin: 0;
  159. }
  160. /* menu entries initial state */
  161. .nav-item,
  162. .nav-subitem {
  163. display: -webkit-box;
  164. display: -ms-flexbox;
  165. display: flex;
  166. -webkit-box-orient: horizontal;
  167. -webkit-box-direction: reverse;
  168. -ms-flex-direction: row-reverse;
  169. flex-direction: row-reverse;
  170. -webkit-box-align: end;
  171. -ms-flex-align: end;
  172. align-items: flex-end;
  173. margin: 0;
  174. width: 100%;
  175. position: relative;
  176. clear: both;
  177. color: transparent;
  178. height: 7px;
  179. line-height: 7px;
  180. white-space: nowrap;
  181. -webkit-transform: scaleY(.2);
  182. transform: scaleY(.2);
  183. -webkit-transition: .5s, opacity .1s;
  184. transition: .5s, opacity .1s;
  185. }
  186. .nav-item:nth-child(1),
  187. .nav-item:nth-child(1)::before {
  188. -webkit-transition-delay: 0s;
  189. transition-delay: 0s;
  190. }
  191. .nav-subitem,
  192. .nav-subitem::before {
  193. opacity: 0;
  194. height: 0;
  195. -webkit-transition-delay: .05s;
  196. transition-delay: .05s;
  197. }
  198. .nav-item:nth-child(3),
  199. .nav-item:nth-child(3)::before {
  200. -webkit-transition-delay: .1s;
  201. transition-delay: .1s;
  202. }
  203. .nav-item:nth-child(4),
  204. .nav-item:nth-child(4)::before {
  205. -webkit-transition-delay: .15s;
  206. transition-delay: .15s;
  207. }
  208. .nav-item::before,
  209. .nav-subitem::before {
  210. position: absolute;
  211. content: '';
  212. top: 50%;
  213. width: 100%;
  214. border-radius: 5px;
  215. height: 2px;
  216. background-color: black;
  217. -webkit-transform: scaleY(5);
  218. transform: scaleY(5);
  219. -webkit-transition: .5s;
  220. transition: .5s;
  221. }