exoticpenguins
exoticpenguins

Reputation: 33

responsive navbar isnt showing all options when resized

I'm in need of some web dev help.

i've created a responsive navbar and it works pretty well except on 2 occasions. I'll only mention the first problem for now though.

so the problem is i have 4 options in my navbar (might need to add another one later), and it shows normally when the browser is over 62 em but once under it turns into a drop down menu. It works... although it only shows 3 of the four options and i have no idea what m doing wrong. i've listed the code below for you guys to have a look at.

thank you :)

.header {
  background-color: #1B1B1B;
  box-shadow: 1px 1px 4px 0 rgba(0,0,0,.1);
  position: fixed;
  width: 100%;
  z-index: 3;
	top:0;
}
.header ul {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  background-color: #1B1B1B;
}

.header li a {
  display: block;
  padding: 20px 20px;
  border-right: 1px solid #1B1B1B;
  text-decoration: none;
}

.header li a:hover,
.header .menu-btn:hover {
  background-color: #1B1B1B;
}

.header .logo {
    display: block;
    float: left;
    font-size: 1.5em;
    padding: 10px 20px;
    text-decoration: none;
}

/* navbar */

.header .menu {
  clear: both;
  max-height: 0;
  transition: max-height .2s ease-out;
}

/* menu icon */

.header .menu-icon {
  cursor: pointer;
  float: right;
  padding: 28px 20px;
  position: relative;
  user-select: none;
}

.header .menu-icon .nav-icon {
  background: #333;
  display: block;
  height: 2px;
  position: relative;
  transition: background .2s ease-out;
  width: 18px;
}

.header .menu-icon .nav-icon:before,
.header .menu-icon .nav-icon:after {
  background: #333;
  content: '';
  display: block;
  height: 100%;
  position: absolute;
  transition: all .2s ease-out;
  width: 100%;
}

.header .menu-icon .nav-icon:before {
  top: 0;
}

.header .menu-icon .nav-icon:after {
  top: 0;
}

/* menu button */

.header .menu-btn {
  display: none;
}

.header .menu-btn:checked ~ .menu {
  max-height: 240px;
}

.header .menu-btn:checked ~ .menu-icon .nav-icon {
  background: transparent;
}

.header .menu-btn:checked ~ .menu-icon .nav-icon:before {
  transform: rotate(-45deg);
  top:0;
}

.header .menu-btn:checked ~ .menu-icon .nav-icon:after {
  transform: rotate(45deg);
  top:0;
}


/* media query for navbar */

@media (min-width: 62em) {
  .header li {
    float: left;
  }
  .header li a {
    padding: 20px 60px;
  }
  .header .menu {
    clear: none;
    float: right;
    max-height: none;
  }
  .header .menu-icon {
    display: none;
  }
}
<header class="header">
            <a href="index.html" class="logo">Introspect</a>
            <input class="menu-btn" type="checkbox" id="menu-btn" />
            <label class="menu-icon" for="menu-btn"><span class="nav-icon"></span></label>
            <ul class="menu">
                <li><a href="index.html">HOME</a></li>
                <li><a href="product.html">PLANS</a></li>
				<li><a href="about.html">ABOUT</a></li>
				<li><a href="enquire.html">ENQUIRE</a></li>
            </ul>
    </header>

EDIT: https://codepen.io/exoticpenguins/pen/PoqvgyJ

ive uploaded my page to codepen. check it out there :)

Upvotes: 3

Views: 61

Answers (1)

Cameron Little
Cameron Little

Reputation: 3721

Your max-height is causing the last element to be clipped. Increasing that will show it.

.header .menu-btn:checked ~ .menu {
  max-height: 240px;
}

Try using your browser developer tools to inspect the elements, it's a good way to see this.

Upvotes: 3

Related Questions