Liljeqvist
Coder
I am having an issue with my navigation menu.
I use flexbox to align all the items, but for some reason I cannot get the logo / brand name to line up wtith the burger-icon.
I added space-between to the parent container, because I want the logo on the left side, and the menu-icon on the right side,
but instead the icon appears underneath the logo.
What did I miss in my stylesheet?
[CODE title="HTML"] <nav class="navbar">
<div class="mobile-top-container">
<div class="company-name">
<h1>
<router-link style="color: #ffffff" :to="{ name: 'Home' }"
>Brand</router-link
>
</h1>
</div>
<div class="navigation-icon" @click="toggleNav">
<i class="pi pi-bars"></i>
</div>
</div>
<div class="navbar-links">
<ul>
<li>
<router-link style="color: #ffffff" :to="{ name: 'Menukort' }"
>Menukort</router-link
>
</li>
<li>Bordbestilling</li>
<li>
<router-link style="color: #ffffff" :to="{ name: 'Hotel' }"
>Hotellet</router-link
>
</li>
<li>
<router-link style="color: #ffffff" :to="{ name: 'Selskaber' }"
>Selskaber</router-link
>
</li>
<li>Kontakt</li>
</ul>
</div>
</nav>[/CODE]
[CODE lang="css" title="CSS"]<style scoped>
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 10px;
background-color: #2f3745;
text-decoration: none;
color: #ffffff;
}
.company-name {
margin-left: 20px;
}
nav ul {
display: flex;
margin: 0;
padding: 0;
}
nav ul li {
display: block;
list-style: none;
color: #ffffff;
padding: 20px;
font-size: 1em;
}
nav ul li:hover {
background-color: #555555;
}
.navigation-icon {
padding: 10px;
cursor: pointer;
margin-right: 20px;
display: none;
}
.pi-bars {
font-size: 30px;
color: #fff;
}
.mobile-top-container {
justify-content: space-between;
}
@media (max-width: 800px) {
.navbar {
flex-direction: column;
align-items: flex-start;
}
.navigation-icon {
display: flex;
}
.navbar-links {
display: none;
width: 100%;
transition: all 0.5s;
}
.navbar-links ul {
flex-direction: column;
width: 100%;
transition: all 0.5s;
}
.navbar-links li {
text-align: center;
}
.navbar-links.active {
display: flex;
transition: all 0.5s;
}
}
</style>[/CODE]
I use flexbox to align all the items, but for some reason I cannot get the logo / brand name to line up wtith the burger-icon.
I added space-between to the parent container, because I want the logo on the left side, and the menu-icon on the right side,
but instead the icon appears underneath the logo.
What did I miss in my stylesheet?
[CODE title="HTML"] <nav class="navbar">
<div class="mobile-top-container">
<div class="company-name">
<h1>
<router-link style="color: #ffffff" :to="{ name: 'Home' }"
>Brand</router-link
>
</h1>
</div>
<div class="navigation-icon" @click="toggleNav">
<i class="pi pi-bars"></i>
</div>
</div>
<div class="navbar-links">
<ul>
<li>
<router-link style="color: #ffffff" :to="{ name: 'Menukort' }"
>Menukort</router-link
>
</li>
<li>Bordbestilling</li>
<li>
<router-link style="color: #ffffff" :to="{ name: 'Hotel' }"
>Hotellet</router-link
>
</li>
<li>
<router-link style="color: #ffffff" :to="{ name: 'Selskaber' }"
>Selskaber</router-link
>
</li>
<li>Kontakt</li>
</ul>
</div>
</nav>[/CODE]
[CODE lang="css" title="CSS"]<style scoped>
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 10px;
background-color: #2f3745;
text-decoration: none;
color: #ffffff;
}
.company-name {
margin-left: 20px;
}
nav ul {
display: flex;
margin: 0;
padding: 0;
}
nav ul li {
display: block;
list-style: none;
color: #ffffff;
padding: 20px;
font-size: 1em;
}
nav ul li:hover {
background-color: #555555;
}
.navigation-icon {
padding: 10px;
cursor: pointer;
margin-right: 20px;
display: none;
}
.pi-bars {
font-size: 30px;
color: #fff;
}
.mobile-top-container {
justify-content: space-between;
}
@media (max-width: 800px) {
.navbar {
flex-direction: column;
align-items: flex-start;
}
.navigation-icon {
display: flex;
}
.navbar-links {
display: none;
width: 100%;
transition: all 0.5s;
}
.navbar-links ul {
flex-direction: column;
width: 100%;
transition: all 0.5s;
}
.navbar-links li {
text-align: center;
}
.navbar-links.active {
display: flex;
transition: all 0.5s;
}
}
</style>[/CODE]