web123456

Getting Started with Bootstrap (I)

preamble

Hello everyone! I'm Nine Songs and today I'm going to be sharing aboutBootstrapThe introductory, first of all, the old rules first on themind map


 

Tip: Below is the body of this post, with the following examples for reference

I. Bootstrap

There are three W's when it comes to learning a new technology: What, Why, and Where.

-What is Bootstrap?

Bootstrap is an AmericanTwitterThe company's designers, Mark Otto andJacob Thornton collaboration is based on HTML, CSS,JavaScript The development of a simple, intuitive and robustforward part of sth.Bootstrap provides elegant HTML and CSS specifications , it is written by the dynamic CSS language Less.

        Bootstrap contains

 

  • fabric:Bootstrap provides a basic structure with a grid system, link styles, and backgrounds. This will be explained in detail in the Bootstrap Basic Structure section.
  • CSSBootstrap comes with the following features: global CSS settings, defining basic HTML element styles, extensible classes, and an advanced grid system. This will be explained in detail in the Bootstrap CSS section.
  • subassemblies:Bootstrap includes a dozen reusable components for creating images, dropdown menus, navigation, warning boxes, popup boxes, and more. This will be explained in detail in the Layout Components section.
  • JavaScript PluginBootstrap includes more than a dozen custom jQuery plugins. You can include all of them directly, or you can include them one by one. This will be explained in detail in the Bootstrap plug-ins section.
  • customizableYou can customize Bootstrap components, LESS variables and jQuery plugins to get your own version.

-Why learn Bootstrap

1. Save time

Bootstrap library contains a lot of ready-made code snippets, these codes can add more vitality to your website. web developers do not have to spend time and effort coding, just find the right code, inserted in the right place.

Bootstrap, developers can easily manipulate the window warning box , tooltip boxes , scrollbars , buttons , etc. Bootstrap is the most prominent , it allows you to not have to bother to write scripts .

2. Customization

One of the important aspects of Bootstrap is that you can take it for yourself. You can keep the parts of the framework that you need and discard the ones that you don't. Bootstrap as a whole allows you to tailor the projects you develop to your needs.

3. Detailed description of the document, easier to get started

Bootstrap's documentation is quite impressive, and Bootstrap's documentation has helped us a lot in getting started. We can find all the information we need through the documentation.

4. Responsive design

Responsive Web design (Responsive Web design) is the concept of: centralized creation of the page image layout size, can be intelligently based on user behavior and the use of the device environment (system platform, screen size, screen orientation, etc.) for the corresponding layout, regardless of whether the user is using a laptop or iPad, our page should be able to automatically switch the resolution, image size and related script functions to adapt to different devices. This way, we do not have to be busy adapting to various types of terminals.

5. Browser Support

All types of browsers support Bootstrap without incompatibility issues.

6. Mobile devices are prioritized

The most difficult thing to adapt is the mobile device, when the mobile device has been solved, the other can not also be solved?

-What is Bootstrap used for?

Bootstrap is mostly used for blogs, enterprise portal pages and so on. After all, Twitter is a blogger.

It is not suitable for pages with complex categorization: e.g., Sotheby's.

II. Steps for use

1. Download Bootstrap

Website: /

Download should be all right, under the new version of the line, will not be able to read the document, simple and easy to get started.

2. Introduction of libraries

The code is as follows:

  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <title></title>
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <style>
  7. .aa{
  8. color: white;
  9. background-color: #007BFF;
  10. border: 0px;
  11. width: 50px;
  12. height: 30px;
  13. border-radius: 3px;
  14. }
  15. </style>
  16. <link rel="stylesheet" type="text/css" href="css/"/>
  17. </head>
  18. <body>
  19. <div class="container">
  20. <button class="aa">consult (a document etc)</button>
  21. <hr color="red" />
  22. <button class="btn btn-outline-primary">look for sth.</button>
  23. </div>
  24. <script src="js/jquery-3.3." type="text/javascript" charset="utf-8"></script>
  25. <script src="js/" type="text/javascript" charset="utf-8"></script>
  26. </body>
  27. </html>

III. Cases

1. Query the original implementation of the comparison Bootstrap way to achieve

The original code is as follows:

  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <title></title>
  5. <!-- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> -->
  6. <style>
  7. .aa{
  8. color: white;
  9. background-color: #007BFF;
  10. border: 0px;
  11. width: 50px;
  12. height: 30px;
  13. border-radius: 3px;
  14. }
  15. </style>
  16. <!-- <link rel="stylesheet" type="text/css" href="css/"/> -->
  17. </head>
  18. <body>
  19. <div class="container">
  20. <button class="aa">consult (a document etc)</button>
  21. <hr color="red" />
  22. <button class="btn btn-outline-primary">look for sth.</button>
  23. </div>
  24. <!-- <script src="js/jquery-3.3." type="text/javascript" charset="utf-8"></script>
  25. <script src="js/" type="text/javascript" charset="utf-8"></script>
  26. -->
  27. </body>
  28. </html>

The original effect is as follows:

Bootstrap way code is as follows:

  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <title></title>
  5. <!-- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> -->
  6. <style>
  7. .aa{
  8. color: white;
  9. background-color: #007BFF;
  10. border: 0px;
  11. width: 50px;
  12. height: 30px;
  13. border-radius: 3px;
  14. }
  15. </style>
  16. <link rel="stylesheet" type="text/css" href="css/"/>
  17. </head>
  18. <body>
  19. <div class="container">
  20. <button class="aa">consult (a document etc)</button>
  21. <hr color="red" />
  22. <button class="btn btn-outline-primary">look for sth.</button>
  23. </div>
  24. <script src="js/jquery-3.3." type="text/javascript" charset="utf-8"></script>
  25. <script src="js/" type="text/javascript" charset="utf-8"></script>
  26. </body>
  27. </html>

Bootstrap implementation of the way the effect is as follows:

 

If the class of the big div here is not container, the effect is as follows:

 

2. Bootstrap page in the mobile browser display effect

We want to add the meta_viewport to the head if we want to adapt it to mobile, let's see the result. Let's see the effect.

 

  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <title></title>
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <style>
  7. .aa{
  8. color: white;
  9. background-color: #007BFF;
  10. border: 0px;
  11. width: 50px;
  12. height: 30px;
  13. border-radius: 3px;
  14. }
  15. </style><link rel="stylesheet" type="text/css" href="css/"/>
  16. </head>
  17. <body>
  18. <div class="container">
  19. <button class="aa">consult (a document etc)</button>
  20. <hr color="red" />
  21. <button class="btn btn-outline-primary">look for sth.</button>
  22. </div>
  23. <script src="js/jquery-3.3." type="text/javascript" charset="utf-8"></script>
  24. <script src="js/" type="text/javascript" charset="utf-8"></script>
  25. </body>
  26. </html>

The effect is as follows:

The button pointed to by the arrow is to convert your computer's browser to mobile.

3. Home navigation & search area original realization

The code is as follows:

  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title>Case 3</title>
  5. <style type="text/css">
  6. .aa{
  7. height: 50px;
  8. background-color: #F8F9FA;
  9. line-height: 50px;
  10. }
  11. .bb{
  12. float: left;
  13. margin-left: 50px;
  14. }
  15. .cc{
  16. float: right;
  17. margin-right: 50px;
  18. }
  19. .cc a{
  20. margin-left: 10px;
  21. }
  22. .ss{
  23. background-color: #dcdcdc;
  24. height: 100px;
  25. margin: 20px 50px 0px 50px;
  26. text-align: center;
  27. line-height: 100px;
  28. }
  29. .ss button{
  30. color: white;
  31. background-color: #007BFF;
  32. border: 0px;
  33. width: 50px;
  34. height: 30px;
  35. border-radius: 3px;
  36. }
  37. .ss input{
  38. border: 0px;
  39. width: 200px;
  40. height: 25px;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="aa">
  46. <div class="bb">
  47. Hello and welcome to the Hogwarts Online Bookstore!
  48. </div>
  49. <div class="cc">
  50. <a>home page (of a website)</a>
  51. <a>log in</a>
  52. <a>enrollment</a>
  53. <a>My Cart</a>
  54. </div>
  55. </div>
  56. <div class="ss">
  57. <input type="text"/>
  58. <button>consult (a document etc)</button>
  59. </div>
  60. </body>
  61. </html>

The effect is as follows:

 

4. Home navigation & search area Bootstrap implementation of the framework for building the home page of the bookstore

The code is as follows:

  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title></title>
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <link rel="stylesheet" type="text/css" href="css/"/>
  7. <style>
  8. .navbar-collapse{
  9. flex-grow: 0;/* 1, means the brake will occupy the remaining space of the parent container 0, means it will not occupy */
  10. }
  11. .ss{
  12. height: 100px;
  13. background-color: #dcdcdc;
  14. margin-top: 20px;
  15. }
  16. .form-group{
  17. width: 300px;
  18. margin-left: auto;
  19. margin-right: auto;
  20. margin-top: 31px;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  26. <div class="container">
  27. <a class="navbar-brand" href="#">Hello and welcome to the Hogwarts Online Bookstore!</a>
  28. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup"
  29. aria-expanded="false" aria-label="Toggle navigation">
  30. <span class="navbar-toggler-icon"></span>
  31. </button>
  32. <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
  33. <div class="navbar-nav">
  34. <a class="nav-item nav-link active" href="#">home page (of a website)<span class="sr-only">(current)</span></a>
  35. <a class="nav-item nav-link" href="#">make landfall (of typhoon etc)</a>
  36. <a class="nav-item nav-link" href="#">enrollment</a>
  37. <a class="nav-item nav-link " href="#">My Cart</a>
  38. </div>
  39. </div>
  40. </div>
  41. </nav>
  42. <! -- Grid system to realize part of the frame of the home page -- >!
  43. <div class="container">
  44. <! -- first line -->
  45. <div class="row ss">
  46. <div class="col">
  47. <form>
  48. <div class="form-group">
  49. <div class="input-group mb-3">
  50. <input type="text" class="form-control" placeholder="Keywords for books" aria-label="Recipient's username"
  51. aria-describedby="basic-addon2">
  52. <div class="input-group-append">
  53. <button class="btn btn-primary" type="button">consult (a document etc)</button>
  54. </div>
  55. </div>
  56. </div>
  57. </form>
  58. </div>
  59. </div>
  60. <div class="row">
  61. <! -- second line -->
  62. <div class="col-3" style="background-color: pink;">
  63. Left 3 - Classification of books
  64. </div>
  65. <div class="col-9" style="background-color: skyblue; ">
  66. <! -- Right 9-Rotating Charts & New Books on the Shelf & Popular Books -- >!
  67. <div class="row">
  68. <div class="col">
  69. Right 9 - First Row Rotating Chart
  70. </div>
  71. </div>
  72. <div class="row">
  73. <! -- New books on the shelves in Right 9 -- >!
  74. <div class="col">
  75. ①New books on the shelves
  76. </div>
  77. <div class="col">
  78. ②New Books on the Shelf
  79. </div>
  80. <div class="col">
  81. ③New books on the shelves
  82. </div>
  83. <div class="col">
  84. ④New books on the shelves
  85. </div>
  86. <div class="col">
  87. ⑤ New books on the shelves
  88. </div>
  89. </div>
  90. <div class="row">
  91. <! -- Popular Books in the Right 9 -- >!
  92. <div class="col">
  93. ①Popular Books
  94. </div>
  95. <div class="col">
  96. ②Popular Books
  97. </div>
  98. <div class="col">
  99. ③Popular books
  100. </div>
  101. <div class="col">
  102. ④Popular Books
  103. </div>
  104. <div class="col">
  105. ⑤ Popular Books
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <script src="js/jquery-3.3." type="text/javascript" charset="utf-8"></script>
  112. <script src="js/" type="text/javascript" charset="utf-8"></script>
  113. </body>
  114. </html>

The effect is as follows:


summarize


The above is the content of today's talk, this article is only a simple introduction to the use of bootstrap, if there is any error hope to correct. Thank you.