Learn Bootstrap

NT
0
Bootstrap-tutorial
Introduction
One of the problems with basic HTML design is that a web page may look different on a different browser or device. (e.g. cell phone, tablet and laptop). Therefore, we may need to change the code depending on the browser or device. The the problem can be easily solved by using Bootstrap.
Bootstrap is a framework that uses HTML, CSS and JavaScript in web design. Supported by all
large browsers e.g. Firefox, Opera and Chrome etc. In addition, Bootstrap includes many pre-defined classes for simple structures e.g. drop-down buttons, navigation bar and alerts etc. Lastly, it responds naturally e.g. make-up changes automatically depending on the device e.g. cell phone or laptop etc.
Setup

Bootstrap requires at least 3 performance files that can be downloaded from the Bootstrap website.
bootstrap.css: This file contains various bootstrap CSS.
bootstrap.js : This file contains various JavaScript applications e.g. discounts and warnings etc.
jQuery.js: This file is a jQuery library that can be downloaded from the 'jQuery' website.
Required for proper operation of 'botstrap.js'.
Download and include files

These files are downloaded and stored within the ‘asset’ folder. Next, we need to import these files into HTML document as below,

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

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

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript; choose one of the two! -->

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="asset/js/bootstrap.bundle.min.js"></script>

    <!-- Option 2: Separate Popper and Bootstrap JS -->
    <!--
    <script src="assett/umd/popper.min.js"></script>
    <script src="asset/js/bootstrap.min.js"></script>
    -->
  </body
Add CDN
Another way to upload files is CDN. This way, we don't need to download files, but provide links
in these files, Note that, in this case the code will not work offline mode.
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript; choose one of the two! -->

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js">

    <!-- Option 2: Separate Popper and Bootstrap JS -->
    <!--
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.min.js"></script>
    -->
  </body>
</html>
Check setup

Let's write our first code to check the correct Bootstrap setup.

Note: We do not have to memorize the code to create a 'downgrade' button. All templates are available at Bootstrap website. Copy and paste the code from there and change the code according to need as shown in this study.

<!DOCTYPE html>

<html>

<head>

<title>Bootstrap Tutorial</title>

<!-- CSS -->

<link href="asset/css/bootstrap.

</head>

<body>

    <div class="dropdown">

    <button class="btn btn-success dropdown-toggle" type="button" id="dropdownMenu1" data-toggle=

    ˓→"dropdown" aria-haspopup="true" aria-expanded="true">Dropdown

    <span class="caret"></span>

</button>

<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

    <li><a href="#">Action</a></li>

    <li><a href="#">Another action</a></li>

    <li><a href="#">Something else here</a></li>

    <li role="separator" class="divider"></li>

    <li><a href="#">Separated link</a></li>

</ul>

</div>

<!-- Javascript -->

<!-- put jQuery.js before bootstrap.min.js; and then add custom jquery -->

<script src="asset/js/jquery-3.3.1.min.js"></script>

<script src="asset/js/bootstrap.min.js"></script>

</body>

</html>

web page result:

Bootstrap Dropdown


Grid system

Bootstrap divides each row into 12 columns. Thereafter following the instructions can be used to specify the scope columns

  • col-xxl-4: It will select 4 columns choose any number between 1-12. th 'xxl' stand for extra extra large screen
  • col-xl-4: It will select 4 columns choose any number between 1-12. th 'xxl' stand for extra large screen
  • col-lg-4 : It will select 4 columns. Choose any number between 1-12. The ‘lg’ stand for large screen (e.g. large computer screen).
  • col-md-5 : ‘md’ = medium screen
  • col-sm-3 : ‘sm’ = small screen
  • col-xs-3 : ‘xs’ = extra small screen
  • col-lg-offset-4 : skip first 4 columns. Simimlary use ‘md’, ‘sm’ and ‘xs’ with offset
As mentioned above, each of these recesses has its own container, the beginning of a different class, and transitions. Here's how the grid changes in these rest areas:

xs     <576px 
sm     ≥576px
md     ≥768px
lg     ≥992px
xl     ≥1200px
xxl     ≥1400px

Note:
  • For easy reference, in the code below the CSS code (Rows 9-21) is used to fill in columns with colors
  • and border.
  • Columns (Rows 28-30) should be defined within the 'line' of the section (Line 27).
  • Also, the total width of the individual columns should not exceed 12.
  • Finally, if we use 'col-md-4' without defining 'lg', 'sm' and 'xs', then the rule 'md' will apply to higher
  • screen size 'lg', but not screen size 'sm' and 'xs'. Similarly, if we use '' 'without defining
  • 'lg', 'md' and 'xs', in which case the law will apply to the screen size 'lg' and 'md' but not to 'xs'
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Bootstrap Tutorial</title>
5
6 <!-- CSS -->
7 <link href="asset/css/bootstrap.min.css" rel="stylesheet">
8 <!-- Add Custom CSS below -->
9 <style type="text/css">
10 .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8,
11 .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8,
12 .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8,
13 .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8 {
14 background-color: green;
15 color: white;
16 font-weight: bold;
17 border: 1px solid red;
18 height: 3em; /*height of the box*/
19 text-align: center; /*vertical center the text*/
20 }
21 </style>
22
23 </head>
24
25 <body>
26
27 <div class="row">
28 <div class="col-md-2 col-xs-4">col-md-2, col-xs-4</div>
29 <div class="col-md-6 col-xs-4">col-md-6, col-xs-4</div>
30 <div class="col-md-4 col-xs-4">col-md-4, col-xs-4</div>
31 </div>
32
33
34 <!-- Javascript -->
35 <!-- put jQuery.js before bootstrap.min.js; and then add custom jquery -->
36 <script src="asset/js/jquery-3.3.1.min.js"></script>
37 <script src="asset/js/bootstrap.min.js"></script>
38 </body>
39 </html>

Col-md



Tags

Post a Comment

0Comments
Post a Comment (0)