Chap 03 - Cascading Style Sheet (CSS)
Chap 03 - Cascading Style Sheet (CSS)
Cascading Style
Sheet (CSS)
Prepared for:
CSC264 – Introduction to Web and
Mobile Application
OVERVIEW OF THIS CHAPTER
Advantages of CSS:
saves time, pages load faster, easy
maintenance,
multiple device compatibility.
INTRODUCTION TO CSS
Three (3) ways to write CSS :
1) Inline CSS : In line
2) Internal CSS
:
<head>
<style>
p{ Write it in head of the web
c page
o
l
}o <body>
</style>r <p> This is a paragraph. </p>
</head> : </body>
r
e
INTRODUCTION TO CSS
<head>
<link rel=“ stylesheet ” type=“text/css”
href=“mystyle.css”>
</head>
selector {
property:value;
}
Html element
selector table {
border:1px solid black;
}
property value
TYPES OF SELECTORS
The HTML Element selector:
The syntax for the selector (e.g. <h1>, <table>, <p>,
etc.) :
h1 {
color:#32a8a4;
font-size:30px;
}
Browser
HTML file
CSS file
TYPES OF SELECTORS
The Class selector:
The syntax for the
selector :
.className {
property:value;
}
Browser
Browser
Must write ID on
HTML file the HTML
file
CSS file
GROUPING SELECTORS
Browser
HTML file
CSS file
CSS MEASUREMENT UNITS
div {
cm Defines a measurement in centimeters. margin-bottom: 2cm;
}
p {
px Defines a measurement in screen pixels. padding: 25px;
}
CSS LINKS
Style Description
:link Signifies unvisited hyperlinks
Multiple
-
column
MULTIPLE-COLUMN
Style Description
Specifies the number of columns an
column-count
element should be divided into
column-gap Specifies the gap between columns
column-width Specifies the width of each columns
column-rule-style
Specifies the style of the rule (line)
between
columns
column-rule-width
Specifies the width of the rule (line)
between
columns
column-rule-color Specifies the color of the rule (line)
between columns
MULTIPLE-COLUMN
HTM L file
CSS file
Browser
RESPONSIVE DESIGN
Why used
RESPONSIVE DESIGN CSS?
Large HD Desktop / TV
Screen Normal Desktop Tablets Smart
phones
MEDIA QUERIES
Media queries basics:
The simplest media query syntax looks
like this:
Browser
Mobile Phone
s
GRID VIEW
What is
GRID-VIEW?
HTML file
Browser
CSS file
GRID VIEW
Define grid-view by screens :
To define responsive grid-view for any devices, need to use 12
columns to have more control over the web page.
1) Need to calculate the percentage for
one column : 100 % / 12 columns =
8.33%
2) Make one class for each of the 12 columns, class=“col-” and a
number defining how many columns the section should span:
GRID VIEW
Example of grid-view by
screens :
CSS file
HTML file
For
desktop
For mobile
phone
GRID VIEW
Example of grid-view by
screens :
Desktop
Mobile Phone
GRID VIEW
Example of grid-view by screens :