天天看点

Bootstrap学习笔记-2

  1. 一个栅格的例子

    项目结构

  2. Bootstrap学习笔记-2
<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
  href="${pageContext.request.contextPath}/bootstrap3/css/bootstrap.min.css">
<link rel="stylesheet"
  href="${pageContext.request.contextPath}/bootstrap3/css/bootstrap-theme.min.css">
<script
  src="${pageContext.request.contextPath}/bootstrap3/js/jquery-1.11.2.min.js"></script>
<script
  src="${pageContext.request.contextPath}/bootstrap3/js/bootstrap.min.js"></script>
<style type="text/css">
.c1 {
  background-color: #CCFF99;
}

.c2 {
  background-color: #FFCCCC;
}

.c3 {
  background-color: #CCEEFF;
}

.c4 {
  background-color: #E6E6FA;
}
</style>
</head>
<body>
  <div class="container">
    <div class="row">
      <div class="col-md-1 c1">.col-md-1</div>
      <div class="col-md-1 c2">.col-md-1</div>
      <div class="col-md-1 c1">.col-md-1</div>
      <div class="col-md-1 c2">.col-md-1</div>
      <div class="col-md-1 c1">.col-md-1</div>
      <div class="col-md-1 c2">.col-md-1</div>
      <div class="col-md-1 c1">.col-md-1</div>
      <div class="col-md-1 c2">.col-md-1</div>
      <div class="col-md-1 c1">.col-md-1</div>
      <div class="col-md-1 c2">.col-md-1</div>
      <div class="col-md-1 c1">.col-md-1</div>
      <div class="col-md-1 c2">.col-md-1</div>
    </div>
    <div class="row">
      <div class="col-md-8 c3">.col-md-8</div>
      <div class="col-md-4 c4">.col-md-4</div>
    </div>
    <div class="row">
      <div class="col-md-4 c1">.col-md-4</div>
      <div class="col-md-4 c2">.col-md-4</div>
      <div class="col-md-4 c1">.col-md-4</div>
    </div>
    <div class="row">
      <div class="col-md-6 c3">.col-md-6</div>
      <div class="col-md-6 c4">.col-md-6</div>
    </div>
  </div>
</body>
</html>      

访问的URL

Bootstrap学习笔记-2
  • 最外层要一个 <div class=“container”>(开发网站一般用container)
  • 最多12列(可不占满)
  • 嵌套的子列,每一列12格
  • 每一嵌套格都是行列嵌套
<div class="row">
  <div class="col-md-1">.col-md-1</div>
  ...(最多12列)
</div>