Search code examples
htmlcsscss-positionfixedmenubar

Position fixed makes code part of element disappear


When I change add the

position: fixed;

to #cssmenu

it makes the right side of the menu disappears

is there any way to fix it? Also do you know why it happens so i do not run into this in the future

if there are more than 1 ways please tell me all

i really need help with this one

the full code is here:

<!DOCTYPE html><html class=''>
<head><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="canonical" href="http://codepen.io/bobbybob123/pen/pJNaqE?editors=110" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:700" >
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:100,100italic">

<style class="cp-pen-styles">*{
  margin: 0;
  padding 0;
}

header{
height: 100vh;
background-image: url("http://nookacorp.com/images/Screenshot%202015-05-26%20at%204.13.50%20PM.png");

width: 100%;
background-size: cover;
background-position: 50% 50%;
}
#cssmenu {
  background: #FFFFFF;
  width: auto;
  
}
#cssmenu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  line-height: 1;
  display: block;
  zoom: 1;
}
#cssmenu ul:after {
  content: " ";
  display: block;
  font-size: 0;
  height: 0;
  clear: both;
  visibility: hidden;
}
#cssmenu ul li {
  display: inline-block;
  padding: 0;
  margin: 0;
}
#cssmenu.align-right ul li {
  float: right;
}
#cssmenu.align-center ul {
  text-align: center;
}
#cssmenu ul li a {
  color: #499CB8;
  text-decoration: none;
  display: block;
  padding: 30px 25px;
  font-family: 'Open Sans', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 14px;
  position: relative;
  -webkit-transition: color .25s;
  -moz-transition: color .25s;
  -ms-transition: color .25s;
  -o-transition: color .25s;
  transition: color .25s;
}
#cssmenu ul li a:hover {
  color: #499CB8;
}
#cssmenu ul li a:hover:before {
  width: 100%;
}
#cssmenu ul li a:after {
  content: "";
  display: block;
  position: absolute;
  right: -3px;
  top: 19px;
  height: 6px;
  width: 6px;
  background: #ffffff;
  opacity: .5;
}
#cssmenu ul li a:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: #499CB8;
  -webkit-transition: width .25s;
  -moz-transition: width .25s;
  -ms-transition: width .25s;
  -o-transition: width .25s;
  transition: width .25s;
}
#cssmenu ul li.last > a:after,
#cssmenu ul li:last-child > a:after {
  display: none;
}
#cssmenu ul li.active a {
  color: #499CB8;
}
#cssmenu ul li.active a:before {
  width: 100%;
}
#cssmenu.align-right li.last > a:after,
#cssmenu.align-right li:last-child > a:after {
  display: block;
}
#cssmenu.align-right li:first-child a:after {
  display: none;
}
@media screen and (max-width: 768px) {
  #cssmenu ul li {
    float: none;
  }

  #cssmenu ul li.last > a,
  #cssmenu ul li:last-child > a {
    border: 0;
  }
  #cssmenu ul li a:after {
    display: none;
  }
  #cssmenu ul li a:before {
    display: none;
  }
}</style></head><body>
<div id='cssmenu'>
<ul>
   <li class='active'><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>Products</span></a></li>
   <li><a href='#'><span>Company</span></a></li>
   <li class='last'><a href='#'><span>Contact</span></a></li>
</ul>
</div>
<header class="heading-top">

<div id="title">
<h1></h1>
</div>

</header>
<section>
<h1>ADDED THIS SO YOU CAN SCROLL</h1>
</section>

<script src='/assets/editor/live/css_live_reload_init.js'></script>
</body></html>


Solution

  • Adding width:100% to #cssmenu should fix your problem