菜单关闭浏览器调整大小

时间:2014-04-22 13:48:18

标签: html css css3

我的水平菜单条形码一直存在问题。

此菜单栏可正确显示1366 x 768分辨率

但是在按下ctrl - 短按键

之后

当我使用ctrl缩小浏览器大小时 - 短按键我的菜单会降下来。我已经尝试使用em和px单位来解决这个问题,但它似乎没有解决问题。我想澄清一下,菜单栏必须与整个页面中的其他内容一致,并且应该针对包装器的整个960px设置进行扩展。我需要帮助来解决这个问题。

以下是我的源代码

HTML

<nav>
  <div class="nav_wrapper">
    <div class="menu_box">
      <div id='cssmenu'>
        <ul>
          <li><a href='index.php' class="active"><span>Home</span></a></li>
          <li><a href='#'><span>About Us</span></a></li>
          <li><a href='#'><span>Courses</span></a>
            <ul>
              <li><a href='index.php'>AGP Program</a></li>
              <li><a href='index.php'>Web Program</a></li>
            </ul>
          </li>
          <li><a href='#'><span>Partners</span></a></li>
          <li><a href='#'><span>Consultancy</span></a></li>
          <li><a href='#'><span>News n Events</span></a></li>
          <li><a href='#'><span>Gallery</span></a></li>
          <li><a href='#'><span>Contact</span></a></li>
        </ul>
      </div>
    </div>
  </div>
</nav>

CSS

/* MEDIA QUERIES FOR A RESPONSIVE LAYOUT */

#cssmenu,
#cssmenu ul,
#cssmenu li,
#cssmenu a {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  font-weight: normal;
  text-decoration: none;
  line-height: 1;
  font-family: 'Arial', sans-serif;
  letter-spacing:0.4px;
  font-size: 14px;
  position: relative;
}
#cssmenu a {
  line-height: 1.5;
}
#cssmenu {
  width: 100%;
  background: #fff;
}
#cssmenu > ul {
  border: 1px solid #000000;
  margin-left:auto;
  margin-right:auto;
  -moz-box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
  -webkit-box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
  background: #565656;
  background: -moz-linear-gradient(#565656 0%, #323232 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #565656), color-stop(100%, #323232));
  background: -webkit-linear-gradient(#565656 0%, #323232 100%);
  background: linear-gradient(#565656 0%, #323232 100%);
}
#cssmenu > ul:after {
  clear: both;
  content: '';
  display: table;
}

@media all and (max-width: 480px) {
  #cssmenu > ul {
    max-height: 32px;
    overflow: hidden;
    -webkit-transition: max-height 0.5s;
    transition: max-height 0.5s;
  }
  #cssmenu.expand ul {
    max-height: 900px;
  }
}

#cssmenu > ul > li {
  border-right: 1px solid #000000;
  -moz-box-shadow: 1px 0 0 rgba(255, 255, 255, 0.2);
  -webkit-box-shadow: 1px 0 0 rgba(255, 255, 255, 0.2);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.2);
  float: left;
}

#cssmenu > ul > li.mobile {
  display: none;
}

#cssmenu > ul > li.active {
  background: #444444;
  background: -moz-linear-gradient(#444444 0%, #323232 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #444444), color-stop(100%, #323232));
  background: -webkit-linear-gradient(#444444 0%, #323232 100%);
  background: linear-gradient(#444444 0%, #323232 100%);
}
@media all and (max-width: 480px) {
  #cssmenu > ul > li {
    border-right:1px solid #000000;
    -moz-box-shadow: 0 0 0 transparent;
    -webkit-box-shadow: 0 0 0 transparent;
    box-shadow: 0 0 0 transparent;
    display: block;
    float: none;
  }
  #cssmenu > ul > li.mobile {
    display: block;
  }
  #cssmenu > ul > li.mobile i {
    float: right;
    font-style: normal;
  }
}
#cssmenu > ul > li:last-child {
  border-right: 0px solid #000000;
  -moz-box-shadow: 0 0 0 transparent;
  -webkit-box-shadow: 0 0 0 transparent;
  box-shadow: 0 0 0 transparent;
  -webkit-border-radius: 0 0px 4px 0;
  -moz-border-radius: 0 0px 4px 0;
  border-radius: 0px;
}
#cssmenu > ul > li:last-child ul {
  left: auto;
  right: 0;
}
#cssmenu > ul > li.mobile {
  border-right: 0 none;
  -moz-box-shadow: 0 0 0 transparent;
  -webkit-box-shadow: 0 0 0 transparent;
  box-shadow: 0 0 0 transparent;
}
#cssmenu > ul > li > a {
  margin: 0 0 2px 0;
  font-size: 12px;
  display: block;
  color: #ffffff;
  text-shadow: 0 1px 1px #000;
}
#cssmenu > ul > li > a > span {
  display: block;
  padding: 6px 2.61em;
  font-weight: bold;
}
#cssmenu > ul > li > a:hover {
  text-decoration: none;
}
#cssmenu > ul > li.active {
  border-bottom: none;
}
#cssmenu > ul > li.active > a {
  color: #fff;
  text-shadow: 0 1px 1px #000;
}
/* Sub menu */
#cssmenu ul ul {
 background: linear-gradient(to bottom, #333333 0%, #000000 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);border: 1px solid #e5e5e5;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 2px;
  -moz-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25);
  -webkit-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25);
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25);
  padding: 5px 12px;
  display: none;
  position: absolute;
  top: 33px;
  left: 0;
  width: 110px;
  z-index: 1;
}
@media all and (max-width: 480px) {
  #cssmenu ul ul {
    position: relative;
    top: 0;
    width: 92%;
  }
}
#cssmenu ul ul li {
  padding: 3px 0;
}
#cssmenu ul ul a {
  color: #999999;
  display: block;
  font-size: 12px;
  font-weight: bold;
}
#cssmenu ul ul li a:hover {
  color: #ffffff;
}

/*  Menus  */       
@media only screen and (min-width: 1000px) 
{   
.middle_section{
        width:100%;
        background-color:#D6D6D6;
/*      background:linear-gradient(to bottom, #C40302 0%, #9E0302 100%) repeat scroll 0 0 rgba(0, 0, 0, 0); */
}

nav{
    background: linear-gradient(#565656 0%, #323232 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);
    clear: both;
    padding-bottom:10px;
    padding-top:10px;
    position: relative;
    width:100%;
}

.nav_wrapper{
    background: linear-gradient(#565656 0%, #323232 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);
    width:960px;
    margin-left:auto;
    margin-right:auto;
}
}

1 个答案:

答案 0 :(得分:0)

这可以通过在包装元素上添加min-width来简单地解决,在这种情况下,我发现它在应用于“nav_wrapper”时效果更好。此外,当使用大于显示的元素时,在body元素中没有边距是好的,所以我也改变了它。

以下是我所做的更改

<强> CSS

body{
        margin: 0px;
    }
.nav_wrapper{
        min-width: 980px;
}

LIVE DEMO