search
HomeWeb Front-endJS TutorialLet's talk about the knowledge points that beginners need to master with Bootstrap

Let's talk about the knowledge points that beginners need to master with Bootstrap

Tutorial recommendation: bootstrap tutorial

Bootstrap

Bootstrap Chinese website: http ://www.bootcss.com/

1. What is Bootstrap?

Official introduction: A simple, intuitive, and powerful front-end development framework that makes web development faster and simpler.

2.Bootstrap Download

Bootstrap3 download address: http://v3.bootcss.com/getting...

3.Bootstrap File directory structure

dist
    -css
        -bootstrap.css
        -bootstrap.css.map
        -bootstrap.min.css(常用)
        -bootstrap-theme.css
        -bootstrap-theme.css.map
        -bootstrap-theme.min.css
    -fonts
        -glyphicons-halflings-regular.eot
        -glyphicons-halflings-regular.svg
        -glyphicons-halflings-regular.ttf
        -glyphicons-halflings-regular.woff
    -js
        -bootstrap.js
        -bootstrap.min.js(常用)
        -npm.js

4.BootstrapDependencies

If you want to use Bootstrap, you must First introduce the jQuery (jquery.min.js) file.

5. UseBootstrap

The compressed version is suitable for practical applications, and the uncompressed version is suitable for development and debugging

  • directly Quote the files downloaded from the official website.

  • Use the free CDN service provided by Bootstrap Chinese website.

<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">

<!-- 可选的Bootstrap主题文件(一般不用引入) -->
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script ></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

6.Bootstrap Basic template

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 基本模板</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn&#39;t work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <h1 id="你好-世界">你好,世界!</h1>

    <!-- jQuery (necessary for Bootstrap&#39;s JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

Bootstrap example selection:http://v3.bootcss.com/getting -started/#examples

Global CSS Style

HTML5 Document Type

Required by some HTML elements and CSS properties used by Bootstrap Set the page as HTML5 document type.

<!DOCTYPE html>
<html>
  ...
</html>

Mobile devices first

Mobile devices are given priority in bootstrap3. To ensure proper drawing and touch scaling, the viewport metadata tag needs to be added to the .

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

On mobile device browsers, you can set the meta attribute to user-scalable=no through the viewport to disable its zooming function, so that the user can only scroll the screen . (It depends on the situation)

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scala=1, user-scalable=no">

Typesetting and linking

Bootstrap typesetting and link styles set basic global styles. They are:

  • ## Set

    background-color for the body element: #fff;

  • Use

    @font-family-base, @font-size-base and @line-height-base a variables as basic parameters for typesetting

  • Sets a basic color for all links

    @link-color, and only adds an underline when the link is in the :hover state

The corresponding source codes for these styles can be found in the

scaffolding.less file.

Normalize.css

In order to enhance the consistency of cross-browser performance, bootstrap uses

Normalize.css, which was developed by Nicolas Gallagher and A CSS reset style library maintained by Jonathan Neal.

Layout container

Bootstrap needs to wrap a

.container container for page content and grid system. Bootstrap provides two classes for this purpose. Note that due to attributes such as padding, these two container classes cannot be nested in each other.

.container class is used for fixed-width containers that support responsive layout.

<div class="container">
  ...
</div>

.container-fluid class is used for containers with 100% width and occupying the entire viewport.

<div class="container-fluid">
  ...
</div>

Grid System<strong></strong>

Bootstrap provides a responsive, mobile-first fluid grid system that scales with screen or viewport size. increases, the system will automatically divide it into up to 12 columns. It contains easy-to-use

predefined classes, as well as powerful mixins for generating more semantic layouts.

Introduction

The grid system is used to create page layouts through a series of combinations of rows and columns. Your content can be placed into these created layouts. middle. Here's an introduction to how the Bootstrap grid system works: <p></p>
  • "Row" must be contained in

    .container (fixed width) or . container-fluid (100% width) to give it proper alignment and padding.

  • Create a group of "columns" in the horizontal direction through "rows". <p></p>
  • Your content should be placed within "column", and only "column" can be a direct child element of row.

  • Predefined classes like

    .row and .col-xs-4 can be used to quickly create grid layouts. In the Bootstrap source code Defined mixins can also be used to create semantic layouts.

  • 通过为“列(column)”设置 padding 属性,从而创建列与列之间的间隔(gutter)。通过为 .row 元素设置负值margin 从而抵消掉为 .container 元素设置的 padding,也就间接为“行(row)”所包含的“列(column)”抵消掉了padding

  • The negative margin is why the examples below are outdented. It's so that content within grid columns is lined up with non-grid content.

  • Grid columns are created by specifying the number of twelve available columns you wish to span. For example, three equal columns would use three .col-xs-4.

  • 如果一“行(row)”中包含了的“列(column)”大于 12,多余的“列(column)”所在的元素将被作为一个整体另起一行排列。

  • Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, applying any .col-md- class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg- class is not present.

通过研究后面的实例,可以将这些原理应用到你的代码中。

媒体查询

在栅格系统中,我们在 Less 文件中使用以下媒体查询(media query)来创建关键的分界点阈值。

/* 超小屏幕(手机,小于 768px) */
/* 没有任何媒体查询相关的代码,因为这在 Bootstrap 中是默认的(还记得 Bootstrap 是移动设备优先的吗?) */

/* 小屏幕(平板,大于等于 768px) */
@media (min-width: @screen-sm-min) { ... }

/* 中等屏幕(桌面显示器,大于等于 992px) */
@media (min-width: @screen-md-min) { ... }

/* 大屏幕(大桌面显示器,大于等于 1200px) */
@media (min-width: @screen-lg-min) { ... }

偶尔也会在媒体查询代码中包含 max-width 从而将 CSS 的影响限制在更小范围的屏幕大小之内

@media (max-width: @screen-xs-max) { ... }
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... }
@media (min-width: @screen-lg-min) { ... }

栅格参数

通过下表可以详细查看 Bootstrap 的栅格系统是如何在多种屏幕设备上工作的。


超小屏幕 手机 ( 小屏幕 平板 (≥768px) 中等屏幕 桌面显示器 (≥992px) 大屏幕 大桌面显示器 (≥1200px)
栅格系统行为 总是水平排列 开始是堆叠在一起的,当大于这些阈值时将变为水平排列C 同左 同左
.container 最大宽度 None (自动) 750px 970px 1170px
类前缀 .col-xs- .col-sm- .col-md- .col-lg-
列(column)数 12 12 12 12
最大列(column)宽 自动 ~62px ~81px ~97px
槽(gutter)宽 30px (每列左右均有 15px) 同左 同左 同左
可嵌套
偏移(Offsets)
列排序

实例:从堆叠到水平排列

使用单一的一组 .col-md-* 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列。所有“列(column)必须放在 ” .row 内。

Lets talk about the knowledge points that beginners need to master with Bootstrap

<div class="row">
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-6">.col-md-6</div>
  <div class="col-md-6">.col-md-6</div>
</div>

实例:移动设备和桌面屏幕

是否不希望在小屏幕设备上所有列都堆叠在一起?那就使用针对超小屏幕和中等屏幕设备所定义的类吧,即 .col-xs-*.col-md-*。请看下面的实例,研究一下这些是如何工作的。

Lets talk about the knowledge points that beginners need to master with Bootstrap

<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
  <div class="col-xs-12 col-md-8">.col-xs-12 .col-md-8</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>

<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
<div class="row">
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>

<!-- Columns are always 50% wide, on mobile and desktop -->
<div class="row">
  <div class="col-xs-6">.col-xs-6</div>
  <div class="col-xs-6">.col-xs-6</div>
</div>

排版

标题

HTML 中的所有标题标签, 均可使用。另外,还提供了 .h1.h6 类,为的是给内联(inline)属性的文本赋予标题的样式

Lets talk about the knowledge points that beginners need to master with Bootstrap

<h1 id="h-nbsp-Bootstrap-nbsp-heading">h1. Bootstrap heading</h1>
<h2 id="h-nbsp-Bootstrap-nbsp-heading">h2. Bootstrap heading</h2>
<h3 id="h-nbsp-Bootstrap-nbsp-heading">h3. Bootstrap heading</h3>
<h4 id="h-nbsp-Bootstrap-nbsp-heading">h4. Bootstrap heading</h4>
<h5 id="h-nbsp-Bootstrap-nbsp-heading">h5. Bootstrap heading</h5>
<h6 id="h-nbsp-Bootstrap-nbsp-heading">h6. Bootstrap heading</h6>

在标题内还可以包含 <small></small> 标签或赋予 .small 类的元素,可以用来标记副标题。

<h1 id="h-nbsp-Bootstrap-nbsp-heading-nbsp-small-Secondary-nbsp-text-small">h1. Bootstrap heading <small>Secondary text</small></h1>
<h2 id="h-nbsp-Bootstrap-nbsp-heading-nbsp-small-Secondary-nbsp-text-small">h2. Bootstrap heading <small>Secondary text</small></h2>
<h3 id="h-nbsp-Bootstrap-nbsp-heading-nbsp-small-Secondary-nbsp-text-small">h3. Bootstrap heading <small>Secondary text</small></h3>
<h4 id="h-nbsp-Bootstrap-nbsp-heading-nbsp-small-Secondary-nbsp-text-small">h4. Bootstrap heading <small>Secondary text</small></h4>
<h5 id="h-nbsp-Bootstrap-nbsp-heading-nbsp-small-Secondary-nbsp-text-small">h5. Bootstrap heading <small>Secondary text</small></h5>
<h6 id="h-nbsp-Bootstrap-nbsp-heading-nbsp-small-Secondary-nbsp-text-small">h6. Bootstrap heading <small>Secondary text</small></h6>

页面主体

Bootstrap 将全局 font-size 设置为 14pxline-height 设置为 1.428。这些属性直接赋予 元素和所有段落元素。另外, (段落)元素还被设置了等于 1/2 行高(即 10px)的底部外边距(margin)。

中心内容

通过添加 .lead 类可以让段落突出显示。

<p class="lead">...</p>

使用 Less 工具构建

variables.less 文件中定义的两个 Less 变量决定了排版尺寸:@font-size-base@line-height-base。第一个变量定义了全局 font-size 基准,第二个变量是 line-height 基准。我们使用这些变量和一些简单的公式计算出其它所有页面元素的 margin、 padding 和 line-height。自定义这些变量即可改变 Bootstrap 的默认样式

内联文本元素

标记文本

为了高亮文本,可以使用 <mark></mark> 标签

You can use the mark tag to <mark>highlight</mark> text.

被删除的文本

对于被删除的文本,可以使用 <del></del> 标签。

Lets talk about the knowledge points that beginners need to master with Bootstrap

<del>This line of text is meant to be treated as deleted text.</del>

无用文本

对于无用文本可以使用 <s></s> 标签。

Lets talk about the knowledge points that beginners need to master with Bootstrap

<s>This line of text is meant to be treated as no longer accurate.</s>

插入文本

而外插入文本使用 <ins></ins> 标签

Lets talk about the knowledge points that beginners need to master with Bootstrap

<ins>This line of text is meant to be treated as an addition to the document.</ins>

带下划线的文本

为文本添加下划线,使用 <u></u> 标签。

Lets talk about the knowledge points that beginners need to master with Bootstrap

<u>This line of text will render as underlined</u>

小号文本

使用标签 <small></small>

着重强调

使用标签 <strong></strong> 标签

斜体

使用 <em></em> 标签

文本对齐

Lets talk about the knowledge points that beginners need to master with Bootstrap

<p class="text-left">Left aligned text.</p>
<p class="text-center">Center aligned text.</p>
<p class="text-right">Right aligned text.</p>
<p class="text-justify">Justified text.</p>
<p class="text-nowrap">No wrap text.</p>

改变大小写

Lets talk about the knowledge points that beginners need to master with Bootstrap

<p class="text-lowercase">Lowercased text.</p>
<p class="text-uppercase">Uppercased text.</p>
<p class="text-capitalize">Capitalized text.</p>

引用

在你的文档中引用其他的来源,可以使用 <blockquote></blockquote> 来表示引用样式。对于直接引用,建议使用 <p></p> 标签。

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>

列表

无序列表

排列顺序无关紧要的一列元素。

<ul>
  <li>...</li>
</ul>
有序列表

顺序至关重要的一组元素

<ol>
  <li>...</li>
</ol>

代码

内联代码

For example, <code><section></code> should be wrapped as inline.

用户输入

通过 kbd 标签标记用户通过键盘输入的内容。

Lets talk about the knowledge points that beginners need to master with Bootstrap

To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>

代码块

多行代码可以使用 <pre class="brush:php;toolbar:false"></pre> 标签。为了正确的展示代码,注意将尖括号做转义处理。

变量

通过 <var></var> 标签标记变量

Program output

Use the <samp></samp> tag to mark the content of the program output

Looking forward to the following articles!

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of Let's talk about the knowledge points that beginners need to master with Bootstrap. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
From Websites to Apps: The Diverse Applications of JavaScriptFrom Websites to Apps: The Diverse Applications of JavaScriptApr 22, 2025 am 12:02 AM

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python vs. JavaScript: Use Cases and Applications ComparedPython vs. JavaScript: Use Cases and Applications ComparedApr 21, 2025 am 12:01 AM

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

The Role of C/C   in JavaScript Interpreters and CompilersThe Role of C/C in JavaScript Interpreters and CompilersApr 20, 2025 am 12:01 AM

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript in Action: Real-World Examples and ProjectsJavaScript in Action: Real-World Examples and ProjectsApr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

JavaScript and the Web: Core Functionality and Use CasesJavaScript and the Web: Core Functionality and Use CasesApr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding the JavaScript Engine: Implementation DetailsUnderstanding the JavaScript Engine: Implementation DetailsApr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: The Learning Curve and Ease of UsePython vs. JavaScript: The Learning Curve and Ease of UseApr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor