gkaroly

hexagon grid menu

Nov 28th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.22 KB | None | 0 0
  1. #hexGrid {
  2. overflow: hidden;
  3. width: 90%;
  4. margin: 0 auto;
  5. padding:0.707% 0;
  6. }
  7.  
  8. #hexGrid:after {
  9. content: "";
  10. display: block;
  11. clear: both;
  12. }
  13.  
  14. .hex {
  15. position: relative;
  16. list-style-type: none;
  17. float: left;
  18. overflow: hidden;
  19. visibility: hidden;
  20. -webkit-transform: rotate(-60deg) skewY(30deg);
  21. -ms-transform: rotate(-60deg) skewY(30deg);
  22. transform: rotate(-60deg) skewY(30deg);
  23. }
  24.  
  25. .hex * {
  26. position: absolute;
  27. visibility: visible;
  28. }
  29.  
  30. .hexIn {
  31. display:block;
  32. width: 100%;
  33. height: 100%;
  34. text-align: center;
  35. color: #fff;
  36. overflow: hidden;
  37. -webkit-transform: skewY(-30deg) rotate(60deg);
  38. -ms-transform: skewY(-30deg) rotate(60deg);
  39. transform: skewY(-30deg) rotate(60deg);
  40. -webkit-backface-visibility: hidden;
  41. backface-visibility: hidden;
  42. }
  43.  
  44.  
  45. /* HEX CONTENT */
  46.  
  47. .hex img {
  48. left: -100%;
  49. right: -100%;
  50. width: auto;
  51. height: 100%;
  52. margin: 0 auto;
  53. }
  54.  
  55. .hex h1, .hex p {
  56. width: 90%;
  57. padding: 0 5%;
  58. background-color: #008080;
  59. background-color: rgba(0, 128, 128, 0.8);
  60. font-family: 'Raleway', sans-serif;
  61. -webkit-transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
  62. transition: top .2s ease-out, bottom .2s ease-out, .2s padding .2s ease-out;
  63. }
  64.  
  65. .hex h1 {
  66. bottom: 110%;
  67. font-style: italic;
  68. font-weight: normal;
  69. font-size: 1.5em;
  70. padding-top: 100%;
  71. padding-bottom: 100%;
  72. }
  73.  
  74. .hex h1:after {
  75. content: '';
  76. display: block;
  77. position: absolute;
  78. bottom: -1px;
  79. left: 45%;
  80. width: 10%;
  81. text-align: center;
  82. z-index: 1;
  83. border-bottom: 2px solid #fff;
  84. }
  85.  
  86. .hex p {
  87. padding-top: 50%;
  88. top: 110%;
  89. padding-bottom: 50%;
  90. }
  91.  
  92.  
  93. /* HOVER EFFECT */
  94.  
  95. .hexIn:hover h1 {
  96. bottom: 50%;
  97. padding-bottom: 10%;
  98. }
  99.  
  100. .hexIn:hover p {
  101. top: 50%;
  102. padding-top: 10%;
  103. }
  104.  
  105. /* SPACING AND SIZING */
  106.  
  107. @media (min-width:1201px) {
  108. .hex {
  109. width: 19.2%; /* = (100-4) / 5 */
  110. padding-bottom: 22.170%; /* = width / sin(60deg) */
  111. }
  112. .hex:nth-child(9n+6),
  113. .hex:nth-child(9n+7),
  114. .hex:nth-child(9n+8),
  115. .hex:nth-child(9n+9) {
  116. margin-top: -4.676%;
  117. margin-bottom: -4.676%;
  118. -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  119. -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  120. transform: translateX(50%) rotate(-60deg) skewY(30deg);
  121. }
  122. .hex:nth-child(9n+6):last-child,
  123. .hex:nth-child(9n+7):last-child,
  124. .hex:nth-child(9n+8):last-child,
  125. .hex:nth-child(9n+9):last-child {
  126. margin-bottom: 0;
  127. }
  128. .hex:nth-child(9n+6) {
  129. margin-left: 0.5%;
  130. clear: left;
  131. }
  132. .hex:nth-child(9n+10) {
  133. clear: left;
  134. }
  135. .hex:nth-child(9n+2),
  136. .hex:nth-child(9n+ 7) {
  137. margin-left: 1%;
  138. margin-right: 1%;
  139. }
  140. .hex:nth-child(9n+3),
  141. .hex:nth-child(9n+4),
  142. .hex:nth-child(9n+8) {
  143. margin-right: 1%;
  144. }
  145. }
  146.  
  147. @media (max-width: 1200px) and (min-width:901px) {
  148. .hex {
  149. width: 24.25%; /* = (100-3) / 4 */
  150. padding-bottom: 28.001%; /* = width / sin(60deg) */
  151. }
  152. .hex:nth-child(7n+5),
  153. .hex:nth-child(7n+6),
  154. .hex:nth-child(7n+7) {
  155. margin-top: -6.134%;
  156. margin-bottom: -6.134%;
  157. -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  158. -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  159. transform: translateX(50%) rotate(-60deg) skewY(30deg);
  160. }
  161. .hex:nth-child(7n+5):last-child,
  162. .hex:nth-child(7n+6):last-child,
  163. .hex:nth-child(7n+7):last-child {
  164. margin-bottom: 0;
  165. }
  166. .hex:nth-child(7n+2),
  167. .hex:nth-child(7n+6) {
  168. margin-left: 1%;
  169. margin-right: 1%;
  170. }
  171. .hex:nth-child(7n+3) {
  172. margin-right: 1%;
  173. }
  174. .hex:nth-child(7n+8) {
  175. clear: left;
  176. }
  177. .hex:nth-child(7n+5) {
  178. clear: left;
  179. margin-left: 0.5%;
  180. }
  181. }
  182.  
  183. @media (max-width: 900px) and (min-width:601px) {
  184. .hex {
  185. width: 32.666%; /* = (100-2) / 3 */
  186. padding-bottom: 37.720%; /* = width / sin(60) */
  187. }
  188. .hex:nth-child(5n+4),
  189. .hex:nth-child(5n+5) {
  190. margin-top: -8.564%;
  191. margin-bottom: -8.564%;
  192. -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  193. -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  194. transform: translateX(50%) rotate(-60deg) skewY(30deg);
  195. }
  196. .hex:nth-child(5n+4):last-child,
  197. .hex:nth-child(5n+5):last-child {
  198. margin-bottom: 0;
  199. }
  200. .hex:nth-child(5n+4) {
  201. margin-right: 1%;
  202. margin-left: 0.5%;
  203. }
  204. .hex:nth-child(5n+2) {
  205. margin-left: 1%;
  206. margin-right: 1%;
  207. }
  208. .hex:nth-child(5n+6) {
  209. clear: left;
  210. }
  211. }
  212.  
  213. @media (max-width: 600px) {
  214. .hex {
  215. width: 49.5%; /* = (100-1) / 2 */
  216. padding-bottom: 57.158%; /* = width / sin(60) */
  217. }
  218. .hex:nth-child(3n+3) {
  219. margin-top: -13.423%;
  220. margin-bottom: -13.423%;
  221. -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  222. -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  223. transform: translateX(50%) rotate(-60deg) skewY(30deg);
  224. }
  225. .hex:nth-child(3n+3):last-child {
  226. margin-bottom: 0;
  227. }
  228. .hex:nth-child(3n+3) {
  229. margin-left: 0.5%;
  230. }
  231. .hex:nth-child(3n+2) {
  232. margin-left: 1%;
  233. }
  234. .hex:nth-child(3n+4) {
  235. clear: left;
  236. }
  237. }
  238. <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,800italic,400,700,800' rel='stylesheet' type='text/css'>
  239. <link href='http://fonts.googleapis.com/css?family=Raleway:400,700,300,200,100,900' rel='stylesheet' type='text/css'>
  240.  
  241. <ul id="hexGrid">
  242. <li class="hex">
  243. <a class="hexIn" href="#">
  244. <img src="https://farm9.staticflickr.com/8461/8048823381_0fbc2d8efb.jpg" alt="" />
  245. <h1>This is a title</h1>
  246. <p>Some sample text about the article this hexagon leads to</p>
  247. </a>
  248. </li>
  249. <li class="hex">
  250. <a class="hexIn" href="#">
  251. <img src="https://farm5.staticflickr.com/4144/5053682635_b348b24698.jpg" alt="" />
  252. <h1>This is a title</h1>
  253. <p>Some sample text about the article this hexagon leads to</p>
  254. </a>
  255. </li>
  256. <li class="hex">
  257. <a class="hexIn" href="#">
  258. <img src="https://farm3.staticflickr.com/2827/10384422264_d9c7299146.jpg" alt="" />
  259. <h1>This is a title</h1>
  260. <p>Some sample text about the article this hexagon leads to</p>
  261. </a>
  262. </li>
  263. <li class="hex">
  264. <a class="hexIn" href="#">
  265. <img src="https://farm7.staticflickr.com/6217/6216951796_e50778255c.jpg" alt="" />
  266. <h1>This is a title</h1>
  267. <p>Some sample text about the article this hexagon leads to</p>
  268. </a>
  269. </li>
  270. <li class="hex">
  271. <a class="hexIn" href="#">
  272. <img src="https://farm7.staticflickr.com/6083/6055581292_d94c2d90e3.jpg" alt="" />
  273. <h1>This is a title</h1>
  274. <p>Some sample text about the article this hexagon leads to</p>
  275. </a>
  276. </li>
  277. </ul>
Advertisement
Add Comment
Please, Sign In to add comment