固定位置使元素的一部分消失

时间:2015-05-26 21:07:29

标签: html css css-position fixed menubar

当我改变时添加

position: fixed;

到#cssmenu

它使菜单的右侧消失

有没有办法解决它?你也知道为什么会这样,所以我将来不会遇到这个问题

如果有多种方式请告诉我所有

我真的需要帮助这个

完整的代码在这里:

<!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>

1 个答案:

答案 0 :(得分:0)

width:100%添加到#cssmenu可以解决您的问题