Bootstrap 4
Bootstrap provides CSS classes to style your webpages on the go. This saves a lot of time building web page. Before start we need to either download the bootstrap and include them in project or refer to bootstrap CDN.
Copy and paste following, that links to bootstrap.min.css beta version 4.2 (latest version as of 5 Jan 2019)
Also copy and paste following javaScript
The template showing where to place the link to bootstrap CSS and javascripts.
the view port meta tag is important to properly scale the page content in different device sizes according to the width of the device.
This example has
The heading uses
The paragraph uses
The button element is styled using the
As you can see, most of the hard work of writing CSS is already done by Bootstrap. Just by using the available classes we can create nice looking websites, and if needed we can customize this classes with our own styles.
Copy and paste following, that links to bootstrap.min.css beta version 4.2 (latest version as of 5 Jan 2019)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
Also copy and paste following javaScript
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" ></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
Template
The template showing where to place the link to bootstrap CSS and javascripts.
<!doctype html> <html lang="en"> <head> <title>Hello, world!</title> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"> </head> <body> <h1>Hello, world!</h1> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" ></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script> </body> </html>
the view port meta tag is important to properly scale the page content in different device sizes according to the width of the device.
Example
<!doctype html> <html lang="en"> <head> <title>Hello, world!</title> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"> </head> <body> <div class = "container"> <div class = "jumbotron"> <h1 class = "display-1"> My First Jumbotron </h1> <p class = "lead">bootstrap is cool</p> <button class = "btn btn-primary">view more</button> </div> <!-- jumbotron close tag--> </div> <!-- container close tag --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" ></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script> </body> </html>
The output
This example has
.container
class that aligns the contents and white spaces at both sides. In the container element we have the jumbo tron, a larger display area. It uses the .jumbotron
bootstrap class. In that jumbo tron we have heading, paragraph and buttonThe heading uses
.display-1
class, which further styles the heading with bigger text and lighter font wight. There are four levels .display-*
classes in bootstrap, where * is number with value 1 to 4 and 1 being the biggest font size.The paragraph uses
.lead
class that alters the text style. This class is used to make the text written in the paragraph out stand.The button element is styled using the
.btn
class and .btn-primary
gives the color to the button, this including the button press and hover actions.Conclusion
As you can see, most of the hard work of writing CSS is already done by Bootstrap. Just by using the available classes we can create nice looking websites, and if needed we can customize this classes with our own styles.
Comments
Post a Comment