As a newcomer to responsive design, I have a question about making the background color disappear when a SPAN element is clicked. Below is my code:
HTML CODE
<body>
<span class="menu-trigger">MENU </span>
<nav class = "nav-main">
<ul>
<li>
<a href = "#" class = "nav-item"> HOME</a>
</li>
<li>
<a href = "#" class = "nav-item">ABOUT US </a>
</li>
<li>
<a href = "#" class = "nav-item">PORTFOLIO </a>
</li>
<li>
<a href = "#" class = "nav-item">SERVICES </a>
</li>
<li>
<a href = "#" class = "navitem">CONTACT US </a>
</li>
</ul>
</nav>
</body>
CSS
@media screen and (max-width: 480px){
.menu-trigger{
display:block;
color:#305782;
background-color: #d5dce4;
padding:10px;
text-align: right;
font-size: 83%;
cursor: pointer;
}
.nav-main {
display:none;
}
.nav-expanded{
display:block;
background-color:none;
}
.nav-main > ul > li{
float:none;
border-bottom: 2px solid #d5dce4;
background-color:black;
}
.main > ul > li:last-child{
border-bottom: none;
}
.nav-main .logo{
display:none;
}
.nav-item:hover {
background-color:forestgreen;
}
}
JQUERY
<script type ="text/javascript">
jQuery( document ).ready(function() {
jQuery(".menu-trigger").click(function(){
jQuery(".nav-main").slideToggle(400, function (){
jQuery(this).toggleClass("nav-expanded").css('display', '');
});
});
});
</script>
JS FIDDLE
https://jsfiddle.net/k4ytvyef/2/ When resizing the screen in mobile view, the HOME option has a long background. How can this be removed?