TI33031 Pemrograman Web I: M Rizki Fadhilah S.T., M.Eng. Prodi Teknik Informatika Fakultas Teknik Universitas Islam Riau
TI33031 Pemrograman Web I: M Rizki Fadhilah S.T., M.Eng. Prodi Teknik Informatika Fakultas Teknik Universitas Islam Riau
TI33031 Pemrograman Web I: M Rizki Fadhilah S.T., M.Eng. Prodi Teknik Informatika Fakultas Teknik Universitas Islam Riau
Pemrograman Web I
M Rizki Fadhilah S.T., M.Eng.
Prodi Teknik Informatika
Fakultas Teknik
Universitas Islam Riau
Week 7 - Bootstrap
What is Bootstrap
● Bootstrap is a free front-end framework for faster and easier
web development
● Bootstrap also gives you the ability to easily create
responsive designs
Why Use Bootstrap?
● Easy to use: Anybody with just basic knowledge of HTML and CSS
can start using Bootstrap
● Responsive features: Bootstrap's responsive CSS adjusts to
phones, tablets, and desktops
● Mobile-first approach: In Bootstrap, mobile-first styles are
part of the core framework
● Browser compatibility: Bootstrap 4 is compatible with all
modern browsers (Chrome, Firefox, Internet Explorer 10+, Edge,
Safari, and Opera)
How To Use Bootstrap
Choose Version
Version 4 : Stable Version 5: Development …
https://getbootstrap.com/ https://v5.getbootstrap.com/
Where to Get Bootstrap 4?
There are two ways to start using Bootstrap 4 on your own web
site.
You can:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
</html>
2. Bootstrap 4 is mobile-first
Bootstrap 4 is designed to be responsive to mobile devices. Mobile-first
styles are part of the core framework. To ensure proper rendering and touch
zooming, add the following <meta> tag inside the <head> element:
The width=device-width part sets the width of the page to follow the
screen-width of the device (which will vary depending on the device).
The initial-scale=1 part sets the initial zoom level when the page is first
loaded by the browser.
3. Containers
Bootstrap 4 also requires a containing element to wrap site contents.
<div class="container">
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
</body>
</html>
Container Fluid Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap 4 Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
</body>
</html>
BS4 Containers
Containers
Bootstrap 4 also requires a containing element to wrap site contents.
Note that its width (max-width) will change on different screen sizes:
<div class="container-fluid">
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
Container Padding
By default, containers have 15px left and right padding, with no top or
bottom padding. Therefore, we often use spacing utilities, such as extra
padding and margins to make them look even better. For example, .pt-3 means
"add a top padding of 16px":
If you do not want to use all 12 columns individually, you can group the
columns together to create wider columns:
Make sure that the sum adds up to 12 or fewer (it is not required that you
use all 12 available columns).
Grid Classes
The classes above can be combined to create more dynamic and flexible layouts.
Tip: Each class scales up, so if you wish to set the same widths for sm and md,
you only need to specify sm.
Basic Structure of a Bootstrap 4 Grid
<!-- Control the column width, and how they should appear on different devices -->
<div class="row">
<div class="col-*-*"></div>
<div class="col-*-*"></div>
</div>
<div class="row">
<div class="col-*-*"></div>
<div class="col-*-*"></div>
<div class="col-*-*"></div>
</div>
● .display-1,
● .display-2,
● .display-3,
● .display-4
BS4 Colors
Text Colors
The .table-bordered class adds borders on all sides of the table and
cells:
BS4 Images
Bootstrap 4 Image Shapes
The .rounded class adds rounded corners to an image:
The .rounded-circle class shapes the image to a circle:
The .img-thumbnail class shapes the image to a thumbnail (bordered):
Responsive Images
Images come in all sizes. So do screens. Responsive images automatically
adjust to fit the size of the screen. Create responsive images by adding
an .img-fluid class to the <img> tag. The image will then scale nicely
to the parent element.
The .img-fluid class applies max-width: 100%; and height: auto; to the
image:
<img class="img-fluid" src="img_chania.jpg" alt="Chania">
BS4 Jumbotron
Bootstrap 4 Jumbotron
A jumbotron indicates a big grey box for calling extra attention to some
special content or information.
<div class="jumbotron">
<h1>Bootstrap Tutorial</h1>
<p>Bootstrap is the most popular HTML, CSS...</p>
</div>
Full-width Jumbotron
If you want a full-width jumbotron without rounded borders, add the
.jumbotron-fluid class and a .container or .container-fluid inside of it:
<div class="btn-group">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
<button type="button" class="btn btn-primary">Sony</button>
</div>
BS4 Badges
Bootstrap 4 Badges
Badges are used to add additional information to any content. Use the .badge
class together with a contextual class (like .badge-secondary) within <span>
elements to create rectangular badges. Note that badges scale to match the
size of the parent element (if any):
To add links inside the navbar, use a <ul> element with class="navbar-nav".
Then add <li> elements with a .nav-item class followed by an <a> element with
a .nav-link class
BS4 Forms
Bootstrap 4's Default Settings
Form controls automatically receive some global styling with Bootstrap:
Note: This only applies to forms within viewports that are at least 576px
wide. On screens smaller than 576px, it will stack horizontally.