0

我正在手动编写我的第一个网站,到目前为止这是一次有趣的冒险,但我遇到了导航菜单的 css 故障。这是我的网站进行中。在我的 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>

和平

4

1 回答 1

0

使用引导程序而不是普通的 CSS。Bootstrap 有助于根据屏幕分辨率 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>

您的完整网站将具有响应性,也可以在移动设备上运行

于 2013-10-30T04:54:23.990 回答