Menu with centered logo
by alstof
HTML
<body>
<header class="header">
<nav class="menu">
<div class="logo" aria-label="logo" role=img></div>
<ul class="menu__list">
<li class="menu__item"><a href="#" target="_blank">Info</a></li>
<li class="menu__item"><a href="#" target="_blank">Photo and video</a></li>
<li class="menu__item"><a href="#" target="_blank">State map</a></li>
<li class="menu__item"><a href="#" target="_blank">Hotels</a></li>
</ul>
</nav>
</header>
SCSS
.menu {
background-color: #fff;
height: 56px;
position: relative;
width: 100%;
transition: transform 0.3s ease-in-out;
&__list {
align-items: center;
outline: 1px solid red;
display: flex;
height: 100%;
justify-content: center;
}
&__item {
outline: 1px solid red;
flex: 1 1 auto;
font-size: 0.9rem;
font-weight: 700;
display: block;
list-style: none;
text-align: center;
width: 25%; // sic!
}
&__item:nth-of-type(2) {
margin-right: 5rem;
}
&__item:nth-of-type(3) {
margin-left: 5rem;
}
&--hidden {
transform: translate(0, -100%);
backface-visibility: hidden;
}
@media screen and (min-width: 25em) {
& {
width: 90vw;
}
}
}
.logo {
background-image: url('http://placehold.it/138x70');
background-position: center center;
background-size: cover;
font-size: 0;
height: 70px;
left: calc(50% - 138px / 2);
position: absolute;
opacity: 0.3;
top: 0;
width: 138px;
}
/*-------------------------------------*\
CSS reset and utils
settings.css
\*-------------------------------------*/
/*
* {
border: 1px solid red;
}
*/
html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}
html, body, nav, section,
footer, div, ul, p, li, h1,
h2, h3, img {
margin: 0;
padding: 0;
}
body {
font-family: 'PT Sans', Lato, Arial, sans-serif;
text-transform: uppercase;
}
h1, h2, p {
padding-left: 1rem;
padding-right: 1rem;
}
a {
color: inherit;
text-decoration: none;
}
@media screen and (min-width: 20em) {
h1, h2, span, p {
padding-left: 0;
padding-right: 0;
}
}
@media screen and (min-width: 25em) {
body {
margin-bottom: 0;
margin-left: auto;
margin-right: auto;
margin-top: 0;
box-shadow: 0 0 30px 5px rgba(0, 0, 0, 0.3);
width: 90vw;
}
}
@media screen and (min-width: 60em) {
span {
display: block;
}
}