javascript - 导航栏太宽

标签 javascript html navbar

我添加了从 W3school 获得的导航栏,但是当我将它添加到我的代码中时,导航栏太宽了,我不确定在哪里可以设置导航栏的宽度或高度。

http://jsfiddle.net/dkx018no/

我的 index.html:

<html>
  <head>
    <meta charset="utf-8">
    <title>Tradeshift</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="http://www.w3schools.com/lib/w3.css" rel="stylesheet"/>
    <script src="http://www.w3schools.com/lib/w3data.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

  </head>

  <nav class="navbar navbar-inverse">
    <div class="container-fluid">
      <div class="navbar-header">
        <a class="navbar-brand" href="#">WebSiteName</a>
      </div>
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Page 1-1</a></li>
            <li><a href="#">Page 1-2</a></li>
            <li><a href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li><a href="#">Page 2</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </nav>

<!-- original img src https://ok2static.oktacdn.com/bc/image/fileStoreRecord?id=fs0d6gmquuO9LX87h0x7 -->
  <div class="jumbotron text-center "> <!--jumbotron is displayed as a grey box with rounded corners. It also enlarges the font sizes of the text inside it.-->
<h1> <img src="https://ok2static.oktacdn.com/bc/image/fileStoreRecord?id=fs0d6gmquuO9LX87h0x7" alt="nothing" border="0">
  <p class="lead">Built on JS/CSS</p><h1>
    <p class="lead"> AJX v1.031018</p>
</div>
  <body>


    <fieldset>
      <div class="text-center">
      <legend>Sign in</legend>

      <div>
        <!--  <label for="userName">Username:</label> -->
          <input type="text" id="username" name="username"
                 required placeholder ="Username"/>
      </div>

      <div>
        <!--  <label for="password">Password:</label> -->
          <input type="password" id="password" name="password"
                 minlength="8" required
                 placeholder="Password" />

    </div>

    <div>
      <form action ="main.html">
        <input type="submit" value="Sign in">
        <div id="button"><a href="register">Register</a></div>
      <!--  <input type="submit" value ="Register" a href ="register"></a> -->
    <!--  <form action="register">
      <input type="submit" value="Register">
    </form> -->
      </form>
    </div>

  </fieldset>

</div>
<script>
w3IncludeHTML();

</script>

  </body>
</html>

最佳答案

您遇到此问题的原因是您同时使用了 Bootstrap 3 和 Bootstrap 4。

由于您使用的元素是 Bootstrap 3 的元素,删除 Bootstrap 4 的链接会对您有所帮助。

这是删除了 Bootstrap 4 的代码。

<html>
  <head>
    <meta charset="utf-8">
    <title>Tradeshift</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="http://www.w3schools.com/lib/w3.css" rel="stylesheet"/>
    <script src="http://www.w3schools.com/lib/w3data.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

  </head>

  <nav class="navbar navbar-inverse">
    <div class="container-fluid">
      <div class="navbar-header">
        <a class="navbar-brand" href="#">WebSiteName</a>
      </div>
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Page 1-1</a></li>
            <li><a href="#">Page 1-2</a></li>
            <li><a href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li><a href="#">Page 2</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </nav>

<!-- original img src https://ok2static.oktacdn.com/bc/image/fileStoreRecord?id=fs0d6gmquuO9LX87h0x7 -->
  <div class="jumbotron text-center "> <!--jumbotron is displayed as a grey box with rounded corners. It also enlarges the font sizes of the text inside it.-->
<h1> <img src="https://ok2static.oktacdn.com/bc/image/fileStoreRecord?id=fs0d6gmquuO9LX87h0x7" alt="nothing" border="0">
  <p class="lead">Built on JS/CSS</p><h1>
    <p class="lead"> AJX v1.031018</p>
</div>
  <body>


    <fieldset>
      <div class="text-center">
      <legend>Sign in</legend>

      <div>
        <!--  <label for="userName">Username:</label> -->
          <input type="text" id="username" name="username"
                 required placeholder ="Username"/>
      </div>

      <div>
        <!--  <label for="password">Password:</label> -->
          <input type="password" id="password" name="password"
                 minlength="8" required
                 placeholder="Password" />

    </div>

    <div>
      <form action ="main.html">
        <input type="submit" value="Sign in">
        <div id="button"><a href="register">Register</a></div>
      <!--  <input type="submit" value ="Register" a href ="register"></a> -->
    <!--  <form action="register">
      <input type="submit" value="Register">
    </form> -->
      </form>
    </div>

  </fieldset>

</div>
<script>
w3IncludeHTML();

</script>

  </body>
</html>

关于javascript - 导航栏太宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52697279/

相关文章:

javascript - 没有点击按钮它的点击事件执行javascript

html - 密码管理器兼容性的正确 HTML 标记和身份验证流程?

css - Bootstrap 下拉菜单菜单栏上的奇怪行为

r - 将 flexdashboard 中的 R markdown 标题链接到应用程序中的页面

javascript - 单击按钮时显示日期选择器

javascript - 模态弹出窗口在桌面上打开视频,但在触摸屏设备上打开应用程序

javascript - 通过jQuery点击功能改变img src

javascript - 如何在给定用户输入 X、Y 点的情况下绘制 HTML5 Canvas 线?

css - 如何制作一个可以在鼠标悬停时单独更改大小的导航栏?

javascript - Grouped_select,如何显示先前选择的项目和/或类别