Bootstrap赢了工作

时间:2016-08-06 12:54:21

标签: html twitter-bootstrap

是的,我是新的,是的,这可能不是一个真正的问题,但它仍然让我烦恼......

这就是我得到的......

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Emmet & Bootstrap</title>

    <link rel="stylesheet" href="dist/css/bootstrap.css">
</head>

<body>

    <div class="navbar">
        <ul>
            <li><a href="#">link 1</a></li>
            <li><a href="#">link 2</a></li>
            <li><a href="#">link 3</a></li>
            <li><a href="#">link 4</a></li>
        </ul>
    </div>

    <!-- JavaScript -->
    <script src="dist/js/jquery.js"></script>
    <script src="dist/js/bootstrap.js"></script>
</body>

</html>

File structure

这就是我得到的......

Result

我错过了什么? (我使用Brackets(基于node.js)实时预览在Chrome中运行此功能)

EDIT1:
@Nhan我想要在引导程序的场景中仍然有效的最小可能的html。即如果我排除bootstrap.css,仍会更改外观的行数最少。我不是在寻找特定的&#34;外观&#34;我只是想从头开始学习bootstrap的基础知识(即我对飞行开始/ ctrl + c,ctrl + v没兴趣)。

2 个答案:

答案 0 :(得分:2)

您缺少大约90%的导航栏相关结构。来自:http://getbootstrap.com/components/#navbar

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <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" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></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 role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left">
        <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" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></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 role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

Bootstrap几乎可以肯定,你需要为它提供正确的工作材料。我将你的导航栏代码放入我知道可行的引导页面中,并且由于缺乏合适的样式和结构而得到了你所看到的完全相同的输出。

答案 1 :(得分:1)

我明白你的意思了。下面是实现Bootstrap导航栏所需的最小标记:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<!-- navbar-default: default colour scheme -->
<nav class="navbar navbar-default">

  <!-- Bootstrap container -->
  <div class="container">

    <!-- Toggle menu on smaller screen sizes (mobile) -->
    <button type="button" class="navbar-toggle collapsed"
            data-toggle="collapse"
            data-target="#bs-example-navbar-collapse-1"> + </button>

    <!-- Bootstrap collapse, work with the button above -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

      <!-- Link list -->
      <ul class="nav navbar-nav">
        <li class="active">
          <a href="#">Link</a>
        </li>
        <li><a href="#">Link</a></li>
      </ul>

    </div>

  </div>
</nav>