导航栏延伸到容器框架外部

时间:2013-10-30 04:38:06

标签: html css nav

我正在手工编写我的第一个网站,到目前为止这是一个有趣的冒险,但我在导航菜单中遇到了一个小故障。 Here's my website-in-progress。在我的15英寸笔记本电脑上,当我最初加载网站时,导航栏延伸到容器的全宽(屏幕宽度的80%),正如我所期望的那样。但是,如果我缩放网页或查看它通过screenfly通过不同的分辨率,导航栏延伸过容器,标题图像变短。任何人都可以帮我弄清楚这是为什么?下面是css,然后是html

*{ margin: 0 auto;}


body {
background:black; 
margin: 0 auto; 
font-family:georgia, times,serif; 
}

#outer-content-wrapper{
    position:relative;
    height:100%;
    width:80%;
    margin:0 auto;
}
#navwrap{
    margin:0;
    height:60px;
    width:100%;
}

#nav{
    position:relative;
    background:black; 
    height:60px;
    width:100%;
    border-top-style:dashed;
    border-bottom-style:dashed;
    border-width:1px;
    border-color:#696969;
    z-index:9000;
    }`

<div id="outer-content-wrapper">
<div id="header">
    <div id="greenlight"></div>
</div>

<div id="navwrap">  
<div id="nav">
    <div id="logo"></div>
        <div class="menu">
            <div class="pagesmenu">
                <ul>
                    <li><a href="#bio">bio</a></li>
                    <li><a href="#music">listen</a></li>
                    <li><a href="#contact">contact</a></li>
                    <li><a href="http://blog.danielLmusic.com">blog</a> </li>
                </ul>
            </div>

和平

1 个答案:

答案 0 :(得分:0)

使用bootstrap而不是plain css。 Bootstraps有助于按照屏幕重新设置http://getbootstrap.com/来处理您的网站。使用我的HTML代码寻求帮助

HTML:

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MENU</title>
<link href="bootstrap.css" rel="stylesheet">
        <link type="text/css" rel="stylesheet" href="custom.css" />
        <link type="text/css" rel="stylesheet" href="css/media.css" />    
        <!--[if lt IE 9]>
        <script src="html5shiv.js"></script>
        <script src= "respond.min.js"></script>
        <![endif]--> 

<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="application.js"></script>
</head>
<body>
<div class="container">

    <nav class="navbar navbar-default" role="navigation">
  <!-- Brand and toggle get grouped for better mobile display -->
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href="#">Brand</a>
  </div>

  <!-- Collect the nav links, forms, and other content for toggling -->
  <div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav">
      <li class="active"><a href="#">Link</a></li>
      <li><a href="#">Link</a></li>
      <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li><a href="#">Separated link</a></li>
          <li><a href="#">One more separated link</a></li>
        </ul>
      </li>
    </ul>
    <form class="navbar-form navbar-left" role="search">
      <div class="form-group">
        <input type="text" class="form-control" placeholder="Search">
      </div>
      <button type="submit" class="btn btn-default">Submit</button>
    </form>
    <ul class="nav navbar-nav navbar-right">
      <li><a href="#">Link</a></li>
      <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li><a href="#">Separated link</a></li>
        </ul>
      </li>
    </ul>
  </div><!-- /.navbar-collapse -->
</nav>
</div>
</body>
</html>

您的完整网站将受到限制,也可以在移动设备上使用