GMR Institute of Technology Rajam, Ap: Class Course Coursecode Preparedby Lecturetopic
GMR Institute of Technology Rajam, Ap: Class Course Coursecode Preparedby Lecturetopic
GMR Institute of Technology Rajam, Ap: Class Course Coursecode Preparedby Lecturetopic
1. Objective
CognitiveLearningLev
els
Knowledge
Remembe Understan Apply Analyze Evaluate Create
Dimension
r d
Factual A
Conceptual A,B,C
Procedural C,D,E
MetaCognitive
4. Teaching Methodology
5. Evocation
6. Deliverables
Lecture 7: Bootstrap: Introduction, Responsive Design, Layouts
https://getbootstrap.com/docs/3.3/css/
• Bootstrap is the most popular and powerful front-end (HTML, CSS, and JavaScript)
framework for faster and easier responsive web development.
• It includes HTML and CSS based design templates for creating common user interface
components like forms, buttons, navigations, dropdowns, alerts, modals, tabs, accordions,
carousels, tooltips, and so on.
• Bootstrap gives you ability to create flexible and responsive web layouts with much less
efforts.
Save lots of time — You can save lots of time and efforts using the Bootstrap predefined design
templates and classes and concentrate on other development work.
Responsive features — Using Bootstrap you can easily create responsive websites that appear more
appropriately on different devices and screen resolutions without any change in markup.
Consistent design — All Bootstrap components share the same design templates and styles through
a central library, so the design and layout of your web pages will be consistent.
Easy to use — Bootstrap is very easy to use. Anybody with the basic working knowledge of HTML,
CSS and JavaScript can start development with Bootstrap.
Compatible with browsers — Bootstrap is created with modern web browsers in mind and it is
compatible with all modern browsers such as Chrome, Firefox, Safari,
Internet Explorer, etc.
Open Source — And the best part is, it is completely free to download and use.
• To create a basic Bootstrap template by including the Bootstrap CSS and JS files via CDN.
• Bootstrap requires a third-party library Popper.js for some of its components like popovers
and tooltips.
• We recommend adding Bootstrap in your project via CDN (Content Delivery Network)
because CDN offers performance benefit by reducing the loading time, since they are hosting
the files on multiple servers spread across the globe so that when a user requests the file it will
be served from the server nearest to them.
In order to make this plain HTML file a Bootstrap template, just include the Bootstrap CSS and JS
files using their CDN links.
Also, you should include JavaScript files at the bottom of the page, right before the closing </body>
tag to improve the performance of your web pages.
CDN links
Description URL
CSS https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css
JS https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js
• The attributes integrity and crossorigin have been added to CDN links to implement
Subresource Integrity (SRI).
• It is a security feature that enables you to mitigate the risk of attacks originating from
compromised CDNs, by ensuring that the files your website fetches (from a CDN or
anywhere) have been delivered without unexpected or malicious modifications.
• Bootstrap requires the use of the HTML5 doctype. Without it, you’ll see some funky and
incomplete styling.
• Bootstrap is developed mobile first, a strategy in which we optimize code for mobile devices
first and then scale up components as necessary using CSS media queries.
• To ensure proper rendering and touch zooming for all devices, add the responsive viewport
meta tag to your <head>.
Layouts in Bootstrap
Containers are the most basic layout element in Bootstrap and they are needed while using the default
grid system.
There are two major layouts for Bootstrap that are Fluid Layout and Fixed Layout.
Fluid-layout: This uses the bootstrap .container-fluid class for the layout.
• This layout uses proportional values such as measuring units for a block of content, images, or
any other item.
• Used for creating an element that is 100 % wider and covers all the screen widths.
• Fluid layout continuously resizes as you change the width of your browser by any amount,
leaving no extra empty space on the sides ever Hence it is named “fluid layout”.
Fixed-layout:
• The fixed-layout has specific pixel width values that change its width value with the help of
media queries.
• Fixed layout resizes in chunks at several certain widths as pixels values are specified.
• Step1: Include Bootstrap and jQuery CDN into the <head> tag before all other stylesheets to
load our CSS.
<link rel=”stylesheet”
href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js”></script> <script
src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js”></script>
Step 2: Add <style> tag and add CSS properties to it that you need.
Step 4: Information must be placed within a .container (fixed layout) or .container-fluid (fluid layout)
class for proper alignment and padding .
• Also, it is fully responsive and uses twelve column system (12 columns available per row) and six
default responsive tiers.
• You can use the Bootstrap's predefined grid classes for quickly making the layouts for different
types of devices like mobile phones, tablets, laptops, desktops, and so on.
• For example, you can use the .col-* classes to create grid columns for extra small devices like
mobile phones in portrait mode, and the .col-sm-* classes for mobile phones in landscape mode.
• Similarly, you can use the .col-md-* classes to create grid columns for medium screen devices like
tablets, the .col-lg-* classes for devices like small laptops, the .col-xl-* classes for laptops and
desktops, and the .col-xxl-* classes for large desktop screens.
<div class="container">
<div class="row">
<div class="col-md-6">Column left</div>
<div class="col-md-6">Column right</div>
</div>
<div class="row">
<div class="col-md-4">Column left</div>
<div class="col-md-8">Column right</div>
</div>
<div class="row">
<div class="col-md-3">Column left</div>
<div class="col-md-9">Column right</div>
</div>
</div>
<div class="container">
<!--Row with three equal columns-->
<div class="row">
<div class="col-lg-4">Column left</div>
<div class="col-lg-4">Column middle</div>
<div class="col-lg-4">Column right</div>
</div>
<div class="container-lg">
<div class="row">
<div class="col-xl-4"><p>Box 1</p></div>
<div class="col-xl-4"><p>Box 2</p></div>
<div class="col-xl-4"><p>Box 3</p></div>
<div class="col-xl-4"><p>Box 4</p></div>
<div class="col-xl-4"><p>Box 5</p></div>
<div class="col-xl-4"><p>Box 6</p></div>
<div class="col-xl-4"><p>Box 7</p></div>
<div class="col-xl-4"><p>Box 8</p></div>
<div class="col-xl-4"><p>Box 9</p></div>
<div class="col-xl-4"><p>Box 10</p></div>
<div class="col-xl-4"><p>Box 11</p></div>
<div class="col-xl-4"><p>Box 12</p></div>
</div>
</div>
The .container-lg class makes the container 100% wide if the width of the viewport is less than 992px,
thus utilizing the full available width on smaller screens.
• Bootstrap greatly simplifies the process of styling and alignment of form controls like labels,
input fields, selectboxes, textareas, buttons, etc. through predefined set of classes.
• To create vertical form layouts simply use the predefined margin utility classes for grouping
the labels, form controls, optional form text, and form validation messages.
• You can also create horizontal form layouts where labels and form controls are aligned side-
by-side using the Bootstrap grid classes.
• To create a horizontal form layout add the class .row on form groups and use the .col-*-* grid
classes to specify the width of your labels and controls.
• Also, be sure to apply the class .col-form-label on the <label> elements, so that they're
vertically centered with their associated form controls.
• Sometimes you may want to display a series of form controls, and buttons in a single
horizontal row to compact the layout.
• There might be a situation when you just want to display a plain text value next to a form label
instead of a working form control.
• You can do this easily by replacing the class .form-control with the .form-control-plaintext and
applying the attribute readonly.
• The .form-control-plaintext class removes the default styling from the form field, but preserves
the correct margin and padding.
Example:
• You can also match the size of your inputs, textareas and select boxes to the Bootstrap grid
column sizes.
• Simply, place your form controls (i.e. <input>, <textarea>, and <select>) in grid columns.
• By default, any number of custom checkboxes and radio buttons that are immediate sibling
will be vertically stacked and appropriately spaced with .form-check class.
• But, you can also place these custom checkboxes and radio buttons inline (i.e., in the same
line) by simply adding the class .form-check-inline to .form-check element, like this:
Example:
To disable individual form controls such as <input>, <textarea>, <select> just add the attributes
disabled to them and Bootstrap will do the rest.
Example:
• Card replaces panel, well, and thumbnail components in old Bootstrap 3 version.
• The outer wrapper require the base class .card, whereas content can be placed inside the .card-
body element.
• The following example will show you how to create a card with a picture, mixed with some
text content and a button.
• The card component support a wide variety of content, including images, text, list groups,
links, navs, and more.
You can simply use .card with .card-body within, whenever you need to create a padded box.
<div class="m-4">
<div class="card" style="width: 300px;">
<div class="card-body">
<h5 class="card-title">Eiffel Tower</h5>
<h6 class="card-subtitle mb-3 text-muted">Champ de Mars, Paris, France</h6>
<p class="card-text">Built in 1889 Eiffel Tower is one of the most iconic landmarks in the
world.</p>
<a href="#" class="card-link">View pictures</a>
<a href="#" class="card-link">Learn more</a>
</div>
</div>
</div>
• You can also add header and footer within your cards using the .card-header and .card-footer
class, respectively.
You can also place list groups inside the card along with other content types, as shown here.
Bootstrap Collapse
• You can use the Bootstrap collapse JavaScript plugin to easily show and hide (or expand and
collapse) specific elements on a web page.
• Buttons and anchors (i.e. the <button> and <a> elements) are typically used as triggers that are
mapped to the elements you want to toggle.
• You can show and hide elements in Bootstrap by clicking on a button or link via data
attributes without writing any JavaScript code.
• The data-bs-toggle="collapse" attribute is added to the trigger or controller element along with
a attribute data-bs-target (for buttons) or href (for anchors) to automatically assign control of
one or more collapsible elements.
• The data-bs-target or href attribute accepts a CSS selector (such as id selector #myCollapse in
our example) to apply the collapse to a specific element.
• You can optionally add the class .show to the collapsible element in addition to the class
.collapse to make it open by default.
jQuery
<script>
$(document).ready(function(){
$("#myBtn").click(function(){
$("#myCollapse").collapse("toggle");
});
});
</script>
JavaScript
<script>
document.addEventListener("DOMContentLoaded", function(){
var btn = document.getElementById("myBtn");
var element = document.getElementById("myCollapse");
btn.addEventListener("click", function(){
myCollapse.toggle();
});
});
</script>
Bootstrap input group component is a very flexible and powerful component for creating interactive
and elegant form controls, however, it is limited to text input, select, and textarea only.
• Further, wrap the text or icon in a <span> element as well as apply the class .input-group-text
on it and place it before or after the input.
Since Bootstrap 5 you can also prepend or append select box dropdown and textarea form controls.
The list groups are very useful and flexible component for displaying lists of elements in a beautiful
manner.
In most basic form a list group is simply an unordered list with the class
.list-group
whereas, the list items having the
class .list-group-item.
<div class="m-4">
<ul class="list-group">
<li class="list-group-item">Pictures</li>
<li class="list-group-item">Documents</li>
<li class="list-group-item">Music</li>
<li class="list-group-item">Videos</li>
</ul>
</div>
<div class="m-4">
<ul class="list-group">
<li class="list-group-item active">Pictures</li>
<li class="list-group-item">Documents</li>
<li class="list-group-item">Music</li>
<li class="list-group-item disabled">Videos</li>
</ul>
</div>
You can also create list groups where items are numbered through simply adding the modifier
class .list-group-numbered
on the .list-group element, like this:
You can also place Bootstrap's custom checkboxes and radio buttons within the list group items.
• You can also link list group items with the little change in HTML markup.
• Just replace the <li> with <a> tag and use <div> element as a parent instead of <ul>.
• You can also add icons and badges to this list group to make it more elegant.
• You can use the Bootstrap navbar component to create responsive navigation header for your
website or application.
• These responsive navbar will be collapsed on devices having small viewports like mobile
phones but expand when user click the toggle button.
navbar-dark for the dark background colors. Then, customize it with the background color utility
classes, such as .bg-dark, .bg-primary, and so on.
Bootstrap also provides mechanism to create navbar that is fixed to the top, fixed to the bottom, or
stickied to the top (i.e. scrolls with the page until it reaches the top, then stays there).
Apply the position utility class .fixed-top to the .navbar element to fix the navbar at the top of the
viewport, so that it won't scroll with the page.
Bootstrap Popovers
• Popover is a small overlay of content that is used to display secondary information of any
element when it is clicked by a user, like those on the iPad.
• Whereas, popover's title and its content that would display upon trigger or activation can be
specified using the title and data-bs-content attribute respectively.
• Popovers can be triggered via JavaScript — just call the popover() Bootstrap method with the
id, class or any CSS selector of the required element in your JavaScript code.
Flex Box
• Flexbox is used to quickly manage the layout, alignment, and sizing of grid columns,
navigation, components, and more with a full suite of responsive flexbox utilities.
Flexbox Properties:
The "display" utility is used to create a flexible container and transform direct children elements into
flex items.
7. Keywords
❖ CDN
8. SampleQuestions
Remember:
9. Stimulating Question(s)
1. Create a responsive webpage for online examination system.
10. Mind Map
At the end of this session, the facilitator (Teacher) shall randomly pick-up few
students to summarize the deliverables.
12. Reading Materials
A. Programming the World Wide Web, 8th edition Robert W. Sebesta, Pearson.
B. Web Coding Development All In One for Dummies, Paul McFedries, Wiley.
C. Web programming with HTML, XHTML and CSS, 2e, Jon Duckett, Wiley India
D. Web programming Bai, Michael Ekedahl, CENAGE Learning, India edition.
E. An Introduction to Web Design + Programming, Paul S.Wang, India Edition
Student can develop responsive and dynamic web pages after completion of this unit.
-------------------------