The code I have creates space between menu items and centers them both horizontally and vertically within each item.
This is achieved by using a wrapper for the menu items:
.gel-layout {
list-style: none;
direction: ltr;
text-align: left;
display: flex;
flex-flow: row wrap;
flex-grow: 1;
margin-right: 0;
margin-left: -8px;
padding-right: 0;
padding-left: 0;
letter-spacing: -0.31em;
text-rendering: optimizespeed;
}
.gel-layout--middle {
align-items: center;
}
And for each individual item:
.gel-layout__item {
width: 100%;
display: inline-block;
padding-left: 8px;
text-align: left;
vertical-align: top;
box-sizing: border-box;
letter-spacing: normal;
word-spacing: normal;
text-rendering: auto;
}
.gel-layout--fit > .gel-layout__item {
width: auto;
flex: 1 1 auto;
}
.gel-layout--equal > .gel-layout__item {
display: flex;
}
.gel-layout--middle > .gel-layout__item {
vertical-align: middle;
}
Is it possible to achieve the same effect for browsers that do not support flexbox?
html {
box-sizing: border-box;
font-size: 62.5%;
}
html,
body {
background-color: #000000;
color: #ffffff;
margin: 0 auto;
line-height: 1;
height: 100%;
text-rendering: optimizeSpeed;
}
body {
font-size: 160%;
margin: 0;
text-rendering: optimizeLegibility;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
/* autoprefixer: off */
/**
* Grid containing element
*/
a {
color: #fff;
}
path {
fill: #ffffff;
}
.menu__container:after {
content: '';
display: table;
clear: both;
}
.menu__container ul li {
display: inline-block;
vertical-align: middle;
}
.menu__container ul li a {
padding-left: 1rem;
}
.gel-wrap {
max-width: 1008px;
margin: 0 auto;
padding-right: 8px;
padding-left: 8px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
@media (min-width: 25em) {
.gel-wrap {
padding-left: 16px;
padding-right: 16px;
}
}
@media (min-width: 80em) {
.gel-wrap {
max-width: 1280px;
}
}
/**
* A grid row
*/
.gel-layout {
list-style: none;
direction: ltr;
text-align: left;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-flex-grow: 1;
-ms-flex-grow: 1;
flex-grow: 1;
margin-right: 0;
margin-left: -8px;
padding-right: 0;
padding-left: 0;
letter-spacing: -0.31em;
text-rendering: optimizespeed;
}
@media (min-width: 37.5em) {
.gel-layout {
margin-left: -16px;
}
}
.opera-only:-o-prefocus,
.gel-layout {
word-spacing: -0.43em;
}
/**
* A single grid item
*/
.gel-layout__item {
width: 100%;
display: inline-block;
padding-left: 8px;
text-align: left;
vertical-align: top;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
letter-spacing: normal;
word-spacing: normal;
text-rendering: auto;
}
@media (min-width: 37.5em) {
.gel-layout__item {
padding-left: 16px;
}
}
/**
* Layouts with no gutters.
*/
.gel-layout--flush {
margin-left: 0;
}
.gel-layout--flush>.gel-layout__item {
padding-left: 0;
}
/**
* Reversed rendered order of layout items, e.g. items 1, 2, 3, 4 in your
* markup will display in order 4, 3, 2, 1 on your page
*/
.gel-layout--rev {
-webkit-flex-direction: row-reverse;
-ms-flex-direction: row-reverse;
flex-direction: row-reverse;
}
.no-flexbox .gel-layout--rev {
direction: rtl;
text-align: left;
}
.no-flexbox .gel-layout--rev>.gel-layout__item {
direction: ltr;
text-align: left;
}
/**
* Align layout items to the vertical centers of each other
*/
.gel-layout--middle {
-webkit-align-items: center;
-ms-flex-align: center;
-ms-grid-row-align: center;
align-items: center;
}
.gel-layout--middle>.gel-layout__item {
vertical-align: middle;
}
.gel-layout--center {
text-align: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.gel-layout--auto>.gel-layout__item {
width: auto;
}
.gel-layout--no-flex {
min-width: 100%;
}
.gel-layout--no-flex,
.gel-layout--no-flex>.gel-layout__item {
display: block;
display: inline-block;
}
.gel-layout--equal>.gel-layout__item {
display: -webkit-flex;
display: flex;
}
/**
* Allow items to devide the space equally between the number of items
*/
.gel-layout--fit>.gel-layout__item {
width: auto;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
}
/**
* Align a single grid item to the top
*/
.gel-layout__item--top {
-webkit-align-self: flex-start;
-ms-flex-item-align: start;
align-self: flex-start;
}
/**
* Align a single grid item to the center
*/
.gel-layout__item--center {
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
}
/**
* Align a single grid item to the bottom
*/
.gel-layout__item--bottom {
-webkit-align-self: flex-end;
-ms-flex-item-align: end;
align-self: flex-end;
}
.gel-layout--middle {
-webkit-align-items: center;
-ms-flex-align: center;
-ms-grid-row-align: center;
align-items: center;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Cutting-Edge Solutions (Scotland)</title>
</head>
<body>
<div id="root">
<header role="banner" aria-label="Cutting-Edge Solutions (Scotalnd)">
<nav class="menu__container">
<div class="gel-wrap">
<div class="gel-layout gel-layout--middle gel-layout--equal gel-layout--fit">
<div class="gel-layout__item ">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<path d="M20 0 L40 20 L20 40 L0 20"></path>
</svg>
</div>
<div class="gel-layout__item "><a href="/">Home</a></div>
<div class="gel-layout__item "><a href="/oss">OSS</a></div>
<div class="gel-layout__item "><a href="/blog">Blog</a></div>
<div class="gel-layout__item "><a href="/privacy-policy">Privacy Policy</a></div>
</div>
</div>
</nav>
</header>
<div class="gel-wrap">
<h1>Home</h1>
</div>
</div>
</body>
</html>