Web Technologies Week 05-06 (Bootstrap and JavaScript)
Web Technologies Week 05-06 (Bootstrap and JavaScript)
Week 05-06
Introduction to Bootstrap & JavaScript
02 What is Bootstrap?
Recap of
Week
03-04
Prepared by Mian Muhammad Talha 3
Previous Week
• Open Source — And the best part is, it is completely free to download
and use.
Prepared by Mian Muhammad Talha 7
How to Add Bootstrap?
You can use Bootstrap without downloading it by utilizing a content delivery
network (CDN). A CDN hosts the Bootstrap files on their servers, allowing
you to include them in your HTML directly from the CDN.
<!-- Optional: Link to Bootstrap JavaScript and jQuery via CDN -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
Prepared by Mian Muhammad Talha 8
Prepared by Mian Muhammad Talha 9
Basic
Features of
Bootstrap
p-0: No padding.
p-1: Small padding (0.25rem or about 4 pixels).
p-2: Medium padding (0.5rem or about 8 pixels).
p-3: Large padding (1rem or about 16 pixels).
p-4: Extra-large padding (1.5rem or about 24 pixels).
p-5: Huge padding (3rem or about 48 pixels).
<div>
<div class="border border-dark m-0">m-0</div>
<div class="border border-dark p-1">p-1</div>
<div class="border border-dark m-2">m-2</div>
<div class="border border-dark p-3">p-3</div>
<div class="border border-dark m-4">m-4</div>
<div class="border border-dark m-5 p-5">m-5
p-5</div>
<div class="border border-dark m-3 p-4">
This is a content block with medium padding.
</div>
</div>
Spacing Classes
You can use the spacing utility classes to quickly adjust the margin and
padding of an element.
The # character in the classes .mt-#, .pt-#, etc. represents the size of the
margin or padding. The value of the size can be an integer from 0 to 5,
or auto.
<div class="bs-example">
<div class="mt-0">.mt-0</div>
<div class="mt-1">.mt-1</div>
<div class="mt-2">.mt-2</div>
<div class="mt-3">.mt-3</div>
<div class="mt-4">.mt-4</div>
</div>
Prepared by Mian Muhammad Talha 22
Spacing Classes
Containers are the most basic layout element in Bootstrap and are required
when using the grid system. Containers are basically used to wrap content
with some padding. They are also used to align the content horizontally
center on the page in case of fixed width layout.
Explore Bootstrap
Bootstrap is an extensive framework.
While we've touched on its fundamental
concepts so far, there's a wealth of other
features to discover. I encourage you to
delve into additional components like
tables, forms, buttons, and navigation
bars.
• const: Also has block scope like let, but it declares a variable that
cannot be reassigned after its initial value is assigned. It's used for
constants.
Prepared by Mian Muhammad Talha 33
Variables and Data Types
Data
•
Types
Strings: Used to represent text. Enclosed in single (' ') or
double (" ") quotes.
Operators and
Expressions Control Flow and Conditionals
let x = 10; let hour = 14;
let y = 5; if (hour < 12) {
console.log(x + y); // Output: 15 console.log("Good morning!");
console.log(`Sum: ${x + y}`); } else if (hour < 18) {
console.log("Good
Loops and Iteration afternoon!");
} else {
for (let i = 0; i < 5; i++) {
console.log("Good evening!");
console.log(`Iteration ${i}`);
}
}
Functions Objects
function greet(name) { let person = {
return `Hello, ${name}!`; firstName: "Alice",
} lastName: "Johnson",
console.log(greet("Bob")); age: 30,
greet: function() {
Arrays return `Hello, $
{this.firstName}!`;
let colors = ["red", "green", "blue"];
}
colors.push("yellow");
};
console.log(colors);
console.log(person.greet());
Explore JavaScript
JavaScript offers many possibilities. We've
covered the basics, but there's a lot more
to learn. You might want to explore tasks
like changing colors, showing alerts,
making pop-up boxes, and updating
content when you click a button.