Written 12: Bootstrap knowledge

BootStrap

Bootstrap, from Twitter, it is the most popular front-end framework. Bootstrap is based on HTML, CSS, JAVASCRIPT, which is simple and flexible, so that Web developers more quickly.

1 Bootstrap basic structure

Bootstrap is a front-end framework for rapid development of Web applications and Web sites. Bootstrap is based on HTML, CSS, JAVASCRIPT's.

(1) create a framework html: Enter the pycharm, after which tab you can!

1559629180353

(2) Bootstrap installation. You can choose from http://getbootstrap.com/ download the latest version of Bootstrap on. Contains jquery.js , bootstrap.min.js and bootstrap.min.css files, make for a regular HTML document into a template using the Bootstrap. Domestic recommend using the library on Staticfile CDN:

<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

2 Bootstrap CSS

Bootstrap 3 default CSS itself is friendly support for mobile devices. Bootstrap 3 is designed to target mobile device priority, and then the desktop. This is actually a very timely change, because now more and more users use mobile devices. To make Bootstrap develop mobile-friendly website, to ensure proper rendering and touch-screen zoom, you need to add in the head page of the viewport meta tag, as follows:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

width Width property of the control device. Assuming that your site will be with a different screen resolution of the device browser, then set it to device-width to ensure it renders correctly on different devices.

initial-scale = 1.0 ensure that the page loads, the ratio of 1: 1 presentation, there will be no scaling.

  • Responsive image
<img src="..." class="img-responsive" alt="响应式图像">

-responsive IMG class image for the given max-width: 100%; and height: auto; property, so that the image can be scaled, does not exceed the size of its parent element.

.img-responsive {
  display: block;
  height: auto;
  max-width: 100%;
}

This indicates that the associated image rendered as Block . When you display the properties of the elements is set to block, displayed in a block-level elements. Setting height: auto highly relevant elements depends on the browser.

Set max-width is 100% overwrites any width specified by the width attribute. This allows images to support responsive layout more user-friendly.

If you need to use the picture horizontally centered .img-responsive type, use the .center-block type, do not use .text-center.

body {margin: 0;} to remove body margins. See related body set below:

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.428571429;
  color: #333333;
  background-color: #ffffff;
}

The first rule setting body of the default font style for "Helvetica Neue", Helvetica, Arial, Sans-serif . The last rule sets the default background color is white.

1559631518306

2.1 Grid System

Bootstrap provides a responsive, mobile device priority streaming grid system, with the increase of the screen or viewport (the viewport) size, the system will automatically be divided into a maximum of 12. In fact, the page layout.

  • bootstrap grid system (Grid System): Bootstrap contains a priority responsive mobile device, not fixed grid system, apparatus, or may increase the size of the viewport appropriately extended to 12. It includes predefined classes for easy layout options, also it includes powerful features for generating more semantic layouts mixed classes.

1559631684369

  • Grid System Works
    • It must be placed in line .container the class, in order to obtain proper alignment (Alignment) and padding (padding).
    • Use lines to create horizontal group of columns.
    • Content should be placed within the column, and the column can only be a direct child of the line.
    • Predefined grid type, such .row and .col--XS. 4 , can be used to quickly create a grid layout. LESS mixing can be used to more semantic class layout.
    • Column to create a gap between the column contents by padding (padding). The padding by .rows outside the distance (margin) taking the negative, and the last row and first column represents an offset.
    • Grid systems are created by specifying twelve available across the columns you want. For example, to create three equal columns, using three .col--XS. 4 .

1559631858112

  • Stack level
<div class="container">
    <h1>Hello, world!</h1>
 
    <div class="row">
        <div class="col-md-6"  style="background-color: #dedef8; box-shadow: inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 
            eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
            enim ad minim veniam, quis nostrud exercitation ullamco laboris 
            nisi ut aliquip ex ea commodo consequat. 
            </p>
 
            <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem 
            accusantium doloremque laudantium, totam rem aperiam, eaque ipsa 
            quae ab illo inventore veritatis et quasi architecto beatae vitae 
            dicta sunt explicabo. 
            </p>
        </div>
 
        <div class="col-md-6" style="background-color: #dedef8;box-shadow: inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
            <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem 
            accusantium doloremque laudantium.
            </p>
 
            <p> Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, 
            consectetur, adipisci velit, sed quia non numquam eius modi 
            tempora incidunt ut labore et dolore magnam aliquam quaerat 
            voluptatem. 
            </p>
        </div>
    </div>
</div>
  • ...
    Elements are added to ensure the maximum width and center.
  • Once you add a container, then you need to consider in units. Add to
    ...
    And add columns within a row
  • Each row in the grid is 12 units, you can define the size of these units of columns. In our example, there are two columns, each of six units, i.e. 6 + 6 = 12.

2.2 Mobile Phone Tablet Universal size

https://www.runoob.com/bootstrap/bootstrap-grid-system-example3.html

2.3 Layout

<small>本行内容是在标签内</small><br>
<strong>本行内容是在标签内</strong><br>
<em>本行内容是在标签内,并呈现为斜体</em><br>
<p class="text-left">向左对齐文本</p>
<p class="text-center">居中对齐文本</p>
<p class="text-right">向右对齐文本</p>
<p class="text-muted">本行内容是减弱的</p>
<p class="text-primary">本行内容带有一个 primary class</p>
<p class="text-success">本行内容带有一个 success class</p>
<p class="text-info">本行内容带有一个 info class</p>
<p class="text-warning">本行内容带有一个 warning class</p>
<p class="text-danger">本行内容带有一个 danger class</p>
  • abbreviation

    1559633281715

  • address

<address>
  <strong>Some Company, Inc.</strong><br>
  007 street<br>
  Some City, State XXXXX<br>
  <abbr title="Phone">P:</abbr> (123) 456-7890
</address>
<address>
  <strong>Full Name</strong><br>
  <a href="mailto:#">[email protected]</a>
</address>
  • Quote
<blockquote>
  <p>
  这是一个默认的引用实例。这是一个默认的引用实例。这是一个默认的引用实例。这是一个默认的引用实例。这是一个默认的引用实例。这是一个默认的引用实例。这是一个默认的引用实例。这是一个默认的引用实例。
  </p>
</blockquote>
<blockquote>
  这是一个带有源标题的引用。
  <small>Someone famous in <cite title="Source Title">Source Title</cite></small>
</blockquote>
<blockquote class="pull-right">
  这是一个向右对齐的引用。
  <small>Someone famous in <cite title="Source Title">Source Title</cite></small>
</blockquote>
  • List
<h4>有序列表</h4>
<ol>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
</ol>
<h4>无序列表</h4>
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
</ul>
<h4>未定义样式列表</h4>
<ul class="list-unstyled">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
</ul>
<h4>内联列表</h4>
<ul class="list-inline">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
</ul>
<h4>定义列表</h4>
<dl>
  <dt>Description 1</dt>
  <dd>Item 1</dd>
  <dt>Description 2</dt>
  <dd>Item 2</dd>
</dl>
<h4>水平的定义列表</h4>
<dl class="dl-horizontal">
  <dt>Description 1</dt>
  <dd>Item 1</dd>
  <dt>Description 2</dt>
  <dd>Item 2</dd>
</dl>
  • Other publishing

1559633633126

2.4 Code

Bootstrap allows you to display the code in two ways: start and end tags use a unicode variants: < and > .

  • The first is 标签。如果您想要内联显示代码,那么您应该使用 标签。
  • 第二种是
     标签。如果代码需要被显示为一个独立的块元素或者代码有多行,那么您应该使用 
     标签。

1559633788857

1559633902621

2.5 表格

Bootstrap 提供了一个清晰的创建表格的布局。下表列出了 Bootstrap 支持的一些表格元素:

1559633980733

  • 表格类,通过把任意的 .table 包在 .table-responsive class 内,您可以让表格水平滚动以适应小型设备(小于 768px)。当在大于 768px 宽的大型设备上查看时,您将看不到任何的差别。

1559635247252

  • , 和 类

1559635279915

基本表格

<table class="table">
  <caption>基本的表格布局</caption>
  <thead>
    <tr>
      <th>名称</th>
      <th>城市</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Tanmay</td>
      <td>Bangalore</td>
    </tr>
    <tr>
      <td>Sachin</td>
      <td>Mumbai</td>
    </tr>
  </tbody>
</table>

2.6 表单

Bootstrap 提供了下列类型的表单布局:垂直表单(默认),内联表单,水平表单。创建基本表单的步骤:

  • 向父
    元素添加 role="form"
  • 把标签和控件放在一个带有 class .form-group
    中。这是获取最佳间距所必需的。
  • 向所有的文本元素 展示列表选项,通常是那些用户很熟悉的选择列表,比如州或者数字。
  • 使用 multiple="multiple" 允许用户选择多个选项。
<form role="form">
  <div class="form-group">
    <label for="name">选择列表</label>
    <select class="form-control">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
    </select>
    <label for="name">可多选的选择列表</label>
    <select multiple class="form-control">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
    </select>
  </div>
</form>

选择框

  • 静态控件,在一个水平表单内的表单标签后放置纯文本时,请在

    上使用 class .form-control-static

<form class="form-horizontal" role="form">
  <div class="form-group">
    <label class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <p class="form-control-static">[email protected]</p>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword" class="col-sm-2 control-label">密码</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword" placeholder="请输入密码">
    </div>
  </div>
</form>

静态控ä"¶

2.7 按钮

以下样式可用于,

Guess you like

Origin www.cnblogs.com/baiboy/p/11014687.html