So I want to apply some CSS only for the mobile (hamburger) menu. I guess you could do something like an @media screen and (max-width: 600px) style for the width where it changes, but that seems messy.
Is there a style that relates only to the mobile menu? That way I could do something like:
.mobile-menu .nav-link {
colour: red;
padding: 40px;
}
to make only the mobile menu red and padded to 40px, and the desktop menu will remain normal. If there is no set style, what is the best way to create CSS that will affect only mobile menu items?
To help, here is the html code:
<nav class="navbar navbar-expand-md">
<a class="navbar-brand" href="#">
<img class="img-fluid d-md-none" src="images/banner_logo_small.png">
<img class="img-fluid d-none d-md-block" src="images/banner_logo.png">
</a>
<button class="navbar-toggler navbar-dark" type="button" data-toggle="collapse" data-target="#main-navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="main-navigation">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">COMMUNITY SUPPORT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>
And here is the code in the .css:
.navbar {
background:#FF8200;
padding: 0;
}
.nav-link,
.navbar-brand {
color: #fff;
cursor: pointer;
padding: 0;
}
.nav-link {
margin-right: 1em !important;
font-weight: bold;
}
.nav-link:hover {
color: #3D3935;
}
.navbar-collapse {
justify-content: flex-end;
}
.d-md-none .navbar-collapse {
padding: 200px;
color: red;
}
So the aim at the moment is to make just the items in the mobile menu have a padding of 200px and to turn red.
Here is a sample: https://www.codeply.com/p/uVOV67zz6E to play with, with the aim of the menu items in mobile to turn red and in desktop view stay white.
The issue of course is in Bootstrap its the same items in the mobile and desktop menu, bootstrap just changes the css based on page width.