akhuwat-db-lab-12-intro_to_css
akhuwat-db-lab-12-intro_to_css
Spring 2023
CC-215L Database Systems-Lab
Lab-12 Manual
Introduction to Lab:
This lab introduces students the purpose of the using front-end in Database Systems. The lab
discusses the basic CSS and Bootstrap. The fundamental concepts are introduced.
The main topics in this lab includes:
1. Bootstrap Introduction
2. Bootstrap Environment Setup
3. Grid Options and Layout
4. Tables
5. Forms
6. Buttons
7. Responsive Utilities
8. CSS Introduction
9. CSS Types
10. CSS Inline Styling
11. CSS Internal Styling
12. CSS Selector
13. Class as a selector
14. Margin and Padding
15. CSS External Styling
16. Post Lab Assignment
1. Bootstrap Introduction
What is Bootstrap?
• A responsive design framework
• Can built static websites and dynamic web applications
• Mobile first approach
• Browser support
• Easy to get started
Page 1 of 15
Lab-12 Manual
<!DOCTYPE html>
<html lang=‘en’>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title of page</title>
<link href=“css/bootstrap.min.css" rel="stylesheet" />
<script src=“js/respond.js"></script>
</head>
<body>
This is my first homepage.
<b>This text is bold</b>
<!-- JavaScript-->
<script src=“js/jquery.js"></script>
<script src=“js/bootstrap.min.js"></script>
</body>
</html>
Grid Options:
Grid Layout:
Page 2 of 15
Lab-12 Manual
You can also use two grid sizes for different screen sizes:
<div class=”row”>
<div class=”col-md-4 col-xs-6”>
<!-- content -->
Page 3 of 15
Lab-12 Manual
</div>
<div class=”col-md-8 col-xs-6”>
<!-- content -->
</div>
</div>
4. Tables
Table Classes:
– table
– table-striped
– table-bordered
– table-hover
– table-condensed
Table Example:
<thead>
<th><td>Name</td>
<td>Age</td></th>
</thead>
<tbody>
<tr><td>Alice</td><td>20</td></tr>
<tr><td>Bob</td><td>25</td></tr>
</tbody>
</table>
5.Forms
• Bootstrap provides you with following types of forms layouts:
• Vertical (default) Form
• Inline Form • Horizontal Form
• Forms Classes:
Page 4 of 15
Lab-12 Manual
– role=“form”
– class=“form-group”
– class=“form-control”
Form Example:
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="InputEmail1" placeholder="Enter
email"> </div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="InputPassword1"
placeholder="Password">
</div>
<button type="submit" class="btn btn-
default">Submit</button> </form>
6. Buttons
• Buttons can either be button elements, links or input elements. They will all
look like buttons.
• For simple links, use the <a> element and add button styling if needed.
• For forms or dynamic buttons, use the button element.
Button Classes:
• btn
• btn-default
• btn-success
• btn-info
• btn-warning
• btn-danger
• btn-link
Button Sizes:
• btn-lg
• btn-sm
• btn-xs
• btn-block
Page 5 of 15
Lab-12 Manual
Example:
<button class="btn btn-primary">Primary</button>
<a href=“#” class=”btn btn-primary”>Primary</a>
<input type=”submit” class=”btn btn-primary”/>
8. CSS Introduction
What is CSS?
CSS stands for Cascading Style Sheets
CSS describes how HTML elements are to be displayed on screen, paper, or
in other media
CSS saves a lot of work. It can control the layout of multiple web pages all at
once
External stylesheets are stored in CSS files
Page 6 of 15
Lab-12 Manual
9. CSS Types
We can apply CSS styles in three different ways:
1. Inline Styling:
We write the CSS properties inside HTML tags by using style attribute.
2. Internal Styling:
The CSS properties for HTML elements are defined at the top of page by
creating separate tag of style <style></style>
3. External Styling:
The CSS properties for HTML elements are defined in separate file with
extension .css
10. CSS Inline Styling
This styling is used within HTML Tag with style attribute.
Syntax:
Inside HTML start tag use attribute named “style”
In the value of style attribute we define style properties
<tagname style=”property:value;property:value;”>
Text styling:
1.Create h1 tag and write you’re the text “Welcome to my Company”.
2. Apply inline style as:
<!DOCTYPE html>
<html>
<head>
<title>CSS Practice</title>
<\head>
<body>
<h1 style=”color: read; font-family: verdana; font-weight: bold;
background-color: grey; text-align: center”>
Welcome to my company</h1>
Page 7 of 15
Lab-12 Manual
<\body>
</html>
style=”background-color:lightblue;”
Page 8 of 15
Lab-12 Manual
Shortcut in sublime text: Write Lorem and press tab to complete the paragraph
inside the paragraph tag
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum. </p>
2. Create a style tag in the head section.
Page 9 of 15
Lab-12 Manual
Note: We can assign multiple classes to an HTML element but id is unique. An HTML
element will have only one unique id.
In above example we used HTML element as selector.
ID as Selector:
we can define id for HTML elements using id attribute.
1. Create a new Paragraph and define its id:
<p id=”p2”> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum. </p>
2. In CSS to call id we use selector as:
#idname
3. Define style for Paragraph as:
#p2{
text-align: left;
font-weight: bold;
border: dotted;
background-color: slateblue;
font-family: tahoma;
}
Page 10 of 15
Lab-12 Manual
Page 11 of 15
Lab-12 Manual
Page 12 of 15
Lab-12 Manual
Page 13 of 15
Lab-12 Manual
The End
Page 14 of 15