Lecture Bootstrap 17-18-19
Lecture Bootstrap 17-18-19
Lecture Bootstrap 17-18-19
Introduction
What is 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 5 is compatible with all modern
browsers (Chrome, Firefox, Edge, Safari, and Opera..
Where to Get Bootstrap 5?
• There are two ways to start using Bootstrap 5 on your own web site.
• You can:
• <scriptsrc="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/botstrap.bundle.min.js" integrity="sha384-
MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
Create Your First Web Page With Bootstrap 5
• Bootstrap 5 uses HTML elements and CSS properties that require the
HTML5 doctype.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap 5 Example</title>
<meta charset="utf-8">
</head>
</html>
• charset=”utf-8″> is an HTML tag that is used to indicate the web
page's character encoding
• This is useful In order to see the correct content
2. Add <meta> tag Inside Head Element
• To ensure proper rendering and touch zooming, add the following <meta> tag
inside the <head> element:
• The initial-scale=1 part sets the initial zoom level when the page is first loaded by
the browser.
• A viewport is the user's visible area of a webpage.
• A viewport meta tag is HTML (HyperText Markup Language) code that
tells browsers how to control viewport dimensions and scaling. It’s a
key ingredient of responsive web design and ensures your content is
easy to view
Example
<!DOCTYPE html> // Adding HTML 5 doc
<html lang="en"> // declaring html language
<head>
<title>Bootstrap 5 Example</title>
<meta charset="utf-8"> // Adding charset
<meta name="viewport" content="width=device-width, initial-
scale=1"> // Adding meta tag
</head>
Now Include Bootstrap CDN link
<!DOCTYPE html>
<html lang="en"> // declaring html language
<head>
<title>Bootstrap 5 Example</title>
<meta charset="utf-8"> // Adding charset
<meta name="viewport" content="width=device-width, initial-scale=1">
// Adding meta tag
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
// Adding Bootstrap link
</head>
Step 5 : Add Containers
</body>
</html>
output
Fixed Container
Use the .container class to create a responsive, fixed-width container.
Note that its width (max-width) will change on different screen sizes:
Fixed Container example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<linkhref="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.cs
s" rel="stylesheet">
<scriptsrc="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle
.min.js"></script>
</head>
<body>
Cont…
<div class="container">
<h1>My First Bootstrap Page</h1>
<p>This part is inside a .container class.</p>
<p>The .container class provides a responsive fixed width
container.</p>
<p>Resize the browser window to see that the container width will
change at different breakpoints.</p>
</div>
</body>
</html>
Output fixed Container
Container Border and color
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
Container border and color
<div class="container p-5 my-5 border">
<h1>My First Bootstrap Page</h1>
<p>This container has a border and some extra padding and margins.</p>
</div>
</body>
</html>
Output
Bootstrap Typography
• Bootstrap Typography provides a standardized and flexible approach
to text styling, offering various classes for headings, paragraphs, and
inline text elements
Bootstrap 5 Text/Typography
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
Cont.…
<div class="container mt-3">
<p>The font-size of each Bootstrap heading depends on the screen size. Try to resize
the browser window to see the effect.</p>
<h1>h1 Bootstrap heading</h1>
<h2>h2 Bootstrap heading</h2>
<h3>h3 Bootstrap heading</h3>
<h4>h4 Bootstrap heading</h4>
<h5>h5 Bootstrap heading</h5>
<h6>h6 Bootstrap heading</h6>
</div>
</body>
</html>
Output typograpgy
Text Colors
<linkhref="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min
.css" rel="stylesheet">
<scriptsrc="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bun
dle.min.js"></script>
<div class="container mt-3">
<h2>Contextual Colors</h2>
<p>Use the contextual classes to provide "meaning through
colors":</p>
<p class="text-muted">This text is muted.</p>
<p class="text-primary">This text is important.</p>
<p class="text-success">This text indicates success.</p>
<p class="text-info">This text represents some information.</p>
<p class="text-warning">This text represents a warning.</p>
<p class="text-danger">This text represents danger.</p>
<p class="text-secondary">Secondary text.</p>
<p class="text-dark">This text is dark grey.</p>
<p class="text-body">Default body color (often black).</p>
<p class="text-light">This text is light grey (on white background).</p>
<p class="text-white">This text is white (on white background).</p>
</div>
</body>
</html>
output
Background Colors
</body>
</html>
output
Basic Table
</body>
</html>
Basic table output
Striped rows
The .table-striped class adds zebra-stripes to a table:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
Cont..
<div class="container mt-3">
<h2>Striped Rows</h2>
<p>The .table-striped class adds zebra-stripes to a table:</p>
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
Cont…
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>
</div>
</body>
Strips rows output
• The .table-bordered class adds borders on all sides of the table and
cells:Borderless Table
</body>
</html>
Output table border class
Black/Dark Table
The .table-dark class adds a black background to the table:
Dark Stripped table
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
></script>
</head>
Cont. Dark Striped table
<body>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
Cont..Dark stripped table
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
output
Responsive Tables