$ Bootstrap 3-introduction and application to 02-Grid, bootstrap02-grid

Source: Internet
Author: User

$ Bootstrap 3-introduction and application to 02-Grid, bootstrap02-grid

This article mainly includes:

■ Grid Introduction
■ Application Grid
■ Multiple Grids

 

About Grid

In Bootstrap, the page is divided into 12 equal parts, which is the so-called Grid.

 

In Bootstrap, use the class name control, which follows a form similar to ". col-xx-6.

 

The entire page is filled with 2 or 6. Therefore, the number at the end of the class name indicates the number of cells.

 

For example, 3 4 also occupies the entire page.

 

For example, four three are also full of the entire page.

 

For example, 6 2 s also occupy the entire page.

 

In addition, for Class names like ". col-xx-10. col-xx-offset-2", offset represents offset, and 2 represents offset to the right two cells.


The above is worth noting: in the second to last line, when ". col -- xx-3 "placed ". col-xx-3. col-xx-offset-2 "later, due to the size of more than 12 cells ,". col -- xx-3 automatically runs to the beginning of the next line.

 

Application Grid

How to Apply Grid to a section with id as body?
In index.html, add the class = "container" attribute to the section whose id is body.
→ Add the class = "col-md-8" attribute to section whose id is main
→ Add class = "col-md-4" attribute to section with id sidebar


How can we make the header and footer partially apply the Grid?
→ Remove the class = "container" attribute of the div whose id is page and change it to: <div id = "page">
→ Add the class = "container" attribute to the header and change it to: → Add the class = "container" attribute to footer and change it to <footer class = "container">


Above, the header, body, and footer parts all apply the Grid. The main part of the body occupies 8 cells, and the sidebar part of the body occupies 4 cells.

 

So far so good. However, if we reduce the browser width to the screen size of a smartphone, we will see some non-harmonious aspects:

 

For example, the title of a row is added to two rows:

 

For example, you need to slide the horizontal scroll bar to view the full picture of an image that can be completely presented:

For example, the original part on the right is pushed to the bottom.


How can we solve these problems?

 

Multiple Grids

Multiple Grids indicates that a page element can have Multiple class names that indicate the size of cells. Enable different classes for different page widths.

 

In Bootstrap 3,
". Col-lg-xx" indicates the page width> = 1200 pixels.
". Col-md-xx" indicates the page width> = 992 pixels.
". Col-sm-xx" indicates the page width> = 768 pixels.
". Col-xs-xx" indicates the page width <768 pixels.

 

We can assign multiple class names to an html element, which are uniquely represented. In the case of ld, the class occupies several cells, and in the case of md, the class occupies several cells.

 

Suppose we need to consider the sm situation, that is, the face width is greater than or equal to 768 pixels.
→ Add col-sm-9 to class in section with id as main
→ Add a col-sm-3 to the class in sectioin with id sidebar

 

Now, adjust the page width to about 800 pixels.

It can be seen that, as previously set, section with id as main occupies nine cells, and sectioin with id as sidebar occupies three cells.


Next, we will consider the case of xs, that is, the page width is less than 768 pixels.
→ Add col-xs-6 to class in section with id as main
→ Add a col-xs-6 to the class in sectioin with id sidebar

 

Now, adjust the page width to about 590 pixels.

It can be seen that, as previously set, section with id as main occupies 6 cells, and sectioin with id as sidebar occupies 6 cells.

 

However, when the page width is less than 768 pixels, setting both the left and right sides to occupy 6 cells is unlikely to appear in the actual project. The above is just for demonstration. We also need to delete the corresponding class name in this case. Return to the following status:


Reference: WilderMinds

 

The "Beauty of Bootstrap 3" series of classes include:

Beauty of Bootstrap 3 01-download and introduce the beauty of Bootstrap 3 on the page 02-Grid introduction and beauty of APP Bootstrap 3 03-independent lines, text wrapping, image adaptive, hidden elements
How can we make existing websites support bootstrap 3?

Every page must introduce the CSS and JS of BOOTSTRAP and modify the classes of each element. For example, the <button class = "btn-primary"> button </BUTTON>

In version 311, no bootstrap-responsivecss?

No,
Bootstrap-responsive.css
It does not exist in version 3.x, because version 3.x is responsive by default.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.