CSS BASIC FUNDAMENTALS
CSS BASIC FUNDAMENTALS
L S
Basics of
CSS
CS
S
Cascading Style Sheet
makeup
not a programmŤng language, but a styŤng
language
h1
{
}
Propert Valu
y e
<style> tag
<style>
h1 {
color :
red;
} WrŤtŤng style dŤrectly ŤnlŤne on each
</ element
Style Ťs added usŤng the <style> element Ťn the same
style> document
Including
Style
External
Stylesheet
W riting CSS in a separate File & Include Into HTM L file
best way
color:
red;
color:
pink;
color: blue;
color:
green;
Background Color
Property
Used to set the color of
background
background-color: red;
background-color: pink;
background-color: blue;
background-color:
green;
Color
Systems
RGB
color: rgb(255, 0,
0);
color: rgb(0, 255,
0);
google color
pŤcker
Selecto
rs
Universal Class Selector
Selector
*{ .myClass { }
}
Element
Selector
h1 { }
Id Selector
# myId
{}
Practice
Set 1
Q1: Create a simple div with an id
" box" . Add some text content
inside
Set its the div.
background color to
blue.
Ťn css3, latest css -> start and end are Ťntroduced for
language support lŤke arabŤc
Text
Properties
text-decoration
font-weight : 100-
900
font-family :
arial
line-height :
2px
line-height :
3
line-height :
normal
Text
Properties
text-transform
Set id & text "outer" for the first one & "inner" for the
second one. Set the outer div text size to 25px & inner
div text size to 10px.
Level
2
Box
Model in
Box M odel in Widt
h
CSS Margi
Heigh
content n
Height
t
Paddin
Width Borde
g
Border
Paddin
Margin
Heig
Heigh
content
htdefault, it sets the content area height of the
By
t
element
div
{
height: 50px;
}
Widt
h
Widt
content
h default, it sets the content area width of the
By
element
div
{
width: 50px;
}
Border
content
Used to set an element's
border
Borde
r
border-width :
2px;
border-style : solid / ed /
dott
border-color : dashed
black;
Bord
er
Shorthand
border : 2px solid black;
Border
Used to round the corners of an element's outer
border edge
border-radius : 10px;
border-radius : 50% ;
Paddi
content
ng
padding- Paddin
left g
padding-
right
padding-
top
padding-
bottom
Paddi
ng
Shorthand
padding:
50px;
padding: 1px 2px 3px 4px;
top | right | bottom | left -> clockwise
M arg Margi
in content n content
margin-
right
margin-
left
margin-
top
margin-
bottom
M arg
in
Shorthand
margin:
50px; 1px 2px 3px
margin:
4px;
top | right | bottom | left ->
clockwise
Practice
Set 3
Q 1: Create a div with height & width of
Set its background color to green & the border radius
100px.
to 50%.
visibility:
hidden;
position
Units in
CSS
Relative
e
m
re
m
width :
33% ;
margin-left :
50% ;
relative - element is relative to itself. (The top, right, bottom, left, and z-ind
from flow)
z-
index
It decides the stack level of
elements
Overlapping elements with a larger z-index cover those with a
smaller one.
z-index : auto
(0)
z-index : 1 /
2 / ...
z-index : -1 / -
2 / ...
show 3d
space
Background
Image
Used to set an image as
background
Basics of
CSS
Flexbox
Flexible Box
Layout
CO
flex
item
L
cross
axis
flex-direction : row;
(default)
flex-direction : row-
reverse;
flex-direction :
column;
flex-direction : column-
reverse;
Flex
Properties
for Flex Container
justify-content : alignment along the main
axis.
flex-start / flex-end / centre / e-evenly
spac /
flex-grow : how much a flex item will grow relative to the rest of the
flex
spaceitems
is if
available
flex-shrink: how much a flex item will shrink relative to the rest of the
flex items if space is available
@ media (min-width :
600px)
div {{ Ťn today's world everyone has a dŤfferent devŤce wŤth
background-color : thousand of dŤfferent screen sŤzes
Ťf you buŤlt a websŤte people wŤll use Ťt on laptop, bŤg
red; screen computers, an Ťphone, a bŤg screen androŤd phone
or a small screen one, an Ťpad
}} even orŤentatŤon Ťs dŤfferent lŤke landscape or
portraŤt so Ťt's Ťmportant that layout looks
good on all
so we need desŤgn to be responsŤve, respond to dŤfferent
screen sŤzes & orŤentatŤon
M edia
Queries
@media (min-width : 200px) and (min-width :
300px)
div {
{ background-color :
} red;
}
transform:
scale(0.5);
transform: scale(1,
2);
transform:
scaleX(0.5);
transform:
scaleY(0.5);
x & y axŤs
separately
CSS
Transform
translat
e
transform: translate(20px);
transform: translateX(20px);
transform: translateY(20px);