做有态度的前端团队

网易FEG前端团队

bootstrap3入门运用

相信大家对于bootstrap并不陌生,但是对于传说中优先兼容移动端的bootstrap3,则不一定很熟悉。对此我进行了一番入门实践。

引用的文件如下:

<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<script src="js/jquery-2.0.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>

导航部分:

    <nav class="navbar navbar-default" role="navigation">
      <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
              <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="#">校园卡中心</a>
      </div>
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
          <li class="active"><a href="#">挂失记录</a></li>
          <li><a href="#">拾获记录</a></li>
        </ul>
        <form class="navbar-form navbar-left" role="search">
          <div class="form-group">
            <input type="text" class="form-control" placeholder="输入姓名或学号">
          </div>
          <button type="submit" class="btn btn-default">搜索</button>
        </form>
      </div>
    </nav>

表单部分:

<form class="form-horizontal" role="form">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">拾获卡学号</label>
    <div class="col-sm-10">
      <input type="number" class="form-control" placeholder="请输入学号">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">拾获卡姓名</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" placeholder="请输入姓名">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">拾获者手机号</label>
    <div class="col-sm-10">
      <input type="number" class="form-control" placeholder="请输入手机号">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">拾获者微信号</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" placeholder="请输入微信号">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">提交登记</button>
    </div>
  </div>
</form>

使用效果:

PC端视图(兼容IE9+等主流浏览器):
1.png

移动端视图:
菜单默认收起
2.png
菜单展开
3.png

手机阅读请扫描下方二维码:

添加新评论

ali-40.gifali-41.gifali-42.gifali-43.gifali-44.gifali-45.gifali-46.gifali-47.gifali-48.gifali-49.gifali-50.gifali-51.gifali-52.gifali-53.gifali-54.gifali-55.gifali-56.gifali-57.gifali-58.gifali-59.gifali-60.gifali-61.gif