This article mainly brings you an introductory tutorial for beginners based on the Bootstrap framework (recommended). The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look. I hope everyone can have a clearer understanding of boostrap.
Bootstrap novice tutorial
Bootstrap introduction
Bootstrap, from Twitter, is currently the most popular Front-end framework. Bootstrap is based on HTML, CSS, and JAVASCRIPT. It is simple and flexible, making web development faster.
"Row" must be contained in a .container (fixed width) or .container-fluid (100% width) in order to give it proper alignment and padding.
Create a group of "columns" in the horizontal direction through "rows".
Your content should be placed within "column", and only "column" can be a direct child element of row.
Similar to .row Predefined classes like .col-xs-4 can be used to quickly create grid layouts. The mixins defined in the Bootstrap source code can also be used to create semantic layouts by adding columns ( column)" sets the padding attribute to create a gap (gutter) between columns. By setting a negative margin for the .row element to offset the padding set for the .container element, it is indirectly "row" The included "column" offsets the padding.
The negative margin is why the following example lines up the content in the grid column.
Columns in the grid system are represented by the range they span by specifying a value from 1 to 12. For example, three equal-width columns can be created using three .col-xs-4. #If the "column" contained in a "row" is greater than 12, the elements of the extra "column" will be arranged as a whole in another row Grid. Grid classes apply to devices with screen widths greater than or equal to the breakpoint size, and grid classes are overridden for small screen devices. Therefore, any .col-md-* grid classes applied on an element apply to devices with screen widths greater than or equal to the breakpoint size. Breakpoint sized devices, and overriding the grid class for small screen devices. Therefore, applying any .col-lg-* on the element does not affect large screen devices as well. Media queries:
Media queries are very fancy "conditional CSS rules". They only apply the corresponding style to some CSS based on certain specified conditions. Media queries allow you to move, show and hide content based on the viewport size. The following media queries are used in LESS files to create critical breakpoint thresholds in the Bootstrap grid system
Media queries have two parts, first a device specification and then a size. Rules. In the above case, the following rules are set:
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
For all devices with min-width: @screen-sm-min, if the width of the screen is smaller than @screen-sm-max, Some processing will be done. Grid ParametersThe following table provides a detailed look at how Bootstrap's grid system works on various screen devices.
The following table summarizes how the Bootstrap grid system works across multiple devices:
Responsive column weighting Setting
The following example contains 4 grids, but we cannot determine the position of the grid display when browsing on a small device.
In order to solve this problem, you can use the .clearfix class and responsive tools to solve it, as shown in the following example:
<p class="container">
<p class="row" >
<p class="col-xs-6 col-sm-3"
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.</p>
</p>
<p class="col-xs-6 col-sm-3"
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>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut.
</p>
</p>
<p class="clearfix visible-xs"></p>
<p class="col-xs-6 col-sm-3"
style="background-color: #dedef8;
box-shadow:inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
</p>
</p>
<p class="col-xs-6 col-sm-3"
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
</p>
</p>
</p>
</p>
Offset column
Offset is a useful feature for more professional layouts. They can be used to make more space for columns. For example, the .col-xs-* classes do not support offsets, but they can achieve the effect simply by using an empty cell.
To use offsets on large screen displays, use the .col-md-offset-* classes. These classes increase the left margin of a column by * columns, where * ranges from 1 to 11. In the example below, we have
..
, we will use .col-md-offset-3 class to center This p.
<p class="container">
<h1>Hello, world!</h1>
<p class="row">
<p class="col-md-3" >
<h4>第一列</h4>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</p>
</p>
<p class="col-md-9" >
<h4>第二列 - 分为四个盒子</h4>
<p class="row">
<p class="col-md-6" >
<p>
Consectetur art party Tonx culpa semiotics. Pinterest
assumenda minim organic quis.
</p>
</p>
<p class="col-md-6" >
<p>
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>
</p>
<p class="row">
<p class="col-md-6" >
<p>
quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat.
</p>
</p>
<p class="col-md-6" >
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim.
</p>
</p>
</p>
</p>
</p>
</p>