SlideShare a Scribd company logo
1 of 27
Position And it’s Values.
80px
30px
• Definition:
Position property helps in setting the element/object
on a desired location of our choice.
• In addition to it we can add diff values with it to make
it more reliable and attractive.
• Diff values are:
80px
STATIC RELATIVE FIXED ABSOLUTE
30px
80px
30px
80px
30px
STATIC RELATIVE FIXED ABSOLUTE
div.static {
height: 400px;
width: 400px;
left: 80px;
position: static;
background-color:yellow;
}
div.static1{
height: 50px;
width: 50px;
left: 30px;
position: static;
background-color:blue;
}
div.relative {
height: 400px;
width: 400px;
left: 80px;
position: relative;
background-color:yellow;
}
div.relative1{
height: 50px;
width: 50px;
left: 30px;
position: relative;
background-color:blue;
}
div.fixed {
height: 400px;
width: 400px;
left: 80px;
position: fixed;
bottom: 0;
right: 0;
background-color:yellow;
}
div.fixed1{
height: 50px;
width: 50px;
left: 30px;
position: fixed;
bottom: 0;
right: 0;
background-color:blue;
}
div.absolute{
height: 400px;
width: 400px;
left: 80px;
position: relatiive;
background-color:yellow;
}
div.absolute1{
height: 50px;
width: 50px;
left: 30px;
position: absolute;
background-color:blue;
}
80px
30px
80px
30px
Position Property.
The position property specifies the type of positioning
method used for an element.
Syntax (position: value)
• There are four different position values:
static : Syntax (position: static);
relative : Syntax (position: relative);
fixed : Syntax (position: fixed);
absolute : Syntax (position: absolute);
• Elements are then positioned using the top, bottom, left,
and right properties. However, these properties will not
work unless the position property is set first. They also
work differently depending on the position value.
Properties And Values
Value Description
Static Elements renders(in a particular way) in order, as they appear in the
document flow. This is default
Relative The element is positioned relative to its normal position, so "left:20"
adds 20 pixels to the element's LEFT position
Absolute The element is positioned relative to its first positioned (not static)
ancestor element
Fixed The element is positioned relative to the browser window
Meaning of RENDERS in Hindi : प्रस्तुत करनेवाला
OR
जो भी डाटा जजस तररके से वेब पेज पे ललखा गया है उसको उसई तररके से प्रस्तुत करने को हम रेंडररिंग कहते है.
OR
जो भी एललमेंट जजस भी तरह से वेब पेज पे दीखता है उससे रेंडररिंग कहते है
Meaning of RENDERS in English: To present in a particular way
OR
The way that something is performed, written, drawn, etc.
Static
• HTML elements are positioned static by default.
• Static positioned elements are not affected by the top,
bottom, left, and right properties .
• NORMAL FLOW: When top=bottom=right=left=0px;
• An element with position: static; is not positioned in any
special way; it is always positioned according to the normal
flow of the page.
• That means if we initialize left: 10px. It won’t make a
difference as the object will be placed acc to the normal flow
of the page.
<html>
<head>
<style>
div.static {
height: 400px;
width: 400px;
left: 80px;
position: static;
background-color:yellow;
}
div.static1{
height: 50px;
width: 50px;
left: 30px;
position: static;
background-color:blue;
}
</style>
</head>
<body>
<h2>position: static;</h2>
We have created two division classes
named as static and static1 also we have
mentioned the box dimensions and
color.
<p>An element with position: static; is not
positioned in any special way; it is always positioned
according to the normal flow of the page:</p>
<div class="static">
</div>
<div class="static1">
</div>
</body>
</html>
Calling of div classes
One is static and other
is static1.
As we have first mentioned the Yellow
Box class therefore Yellow Box appears
first and then Blue one.
This is called as NORMAL FLOW of the
page means moving from top to bottom.
Static position means that both the
Boxes are static with respect to the
normal flow of the
page(height=width=top=bottom=0) that
means whatever is written first in the
code will be represented first.
The object should be shifted by 10px to
left but it didn’t because the position is
static so it (obj) will be located acc to
the normal flow of the page.
Relative
• An element with position: relative; is positioned
relative to its normal position ( top = bottom =
left =right=0).
• That means if we initialize left:10px . The object will
be shifted by 10px to left with respect to (relative)
the normal flow of the page.
• Setting the top, right, bottom, and left properties of
a relatively-positioned element will cause it to be
adjusted away from its normal position. Other
content will not be adjusted to fit into any gap left
by the element.
<!DOCTYPE html>
<html>
<head>
<style>
div.relative {
height: 400px;
width: 400px;
position: relative;
left:80px;
background-color:yellow;
}
div.relative1{
height: 50px;
width: 50px;
position: relative;
left:30px;
background-color:blue;
}
We have created two division classes
named as relative and relative1 also we
have mentioned the box dimensions and
color.
</style>
</head>
<body>
<h1>position: relative;</h2>
<p>An element with position:
relative; is positioned relative to its
normal position:</p>
<div class=“relative">
</div>
<div class=“relative1">
</div>
</body>
</html>
Calling of div classes
One is relative and
other is relative1.
Both the boxes are
relative with the normal
flow of the page. So
when we set left:80 and
left:30 for yellow and
blue box , the blue box
got shifted to left by
30px and the yellow box
got shifted to left by
80px.
30px
80px
Absolute
• An element with position: absolute; is positioned
relative to the nearest positioned ancestor
(instead of positioned relative to the viewport,
like fixed).
• VIEWPORT: The viewport is the user's visible area
of a web page.
• However; if an absolute positioned element has
no positioned ancestors, it uses the document
body, and moves along with page scrolling.
<!DOCTYPE html>
<html>
<head>
<style>
div.absolute {
height: 400px;
width: 400px;
position: relative;
bottom: 0px;
left: 80px;
background-color:yellow;
}
div.absolute1{
position: absolute;
height: 50px;
width: 50px;
bottom: 0px;
left: 20px;
background-color:blue;}
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position: absolute; is
positioned relative to the nearest positioned
ancestor (instead of positioned relative to the
viewport, like fixed):</p>
<div class=“absolute">
</div>
<div class=“absolute1">
</div>
</body>
</html>
80px
20px
We have created two division classes
named as absolute and absolute1 also
we have mentioned the box dimensions
and color.
The div tag for both the boxes are
opened and closed separately
therefore no effect of absolute
position is showcased here
80px
20px
As both the boxes have
separate opening and
closing of div classes so
there is no effect of
ABSOLUTE position on the
blue box. Therefore the
blue box is shifted to left
by 20px with respect to
the document body
instead of the yellow box.
The correct code..
<!DOCTYPE html>
<html>
<head>
<style>
div.absolute {
height: 400px;
width: 400px;
position: relative;
bottom: 0px;
left: 80px;
background-color:yellow;
}
div.absolute1{
position: absolute;
height: 50px;
width: 50px;
bottom: 0px;
left: 20px;
background-color:blue;}
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position: absolute; is
positioned relative to the nearest positioned
ancestor (instead of positioned relative to the
viewport, like fixed):</p>
<div class=“absolute">
<div class=“absolute1">
</div>
</div>
</body>
</html>
80px
20px
The div tag for the blue box is
nested in the div tag for yellow
box . That means the div tag for
blue box is inside the div tag of
yellow box.
We have created two division classes
named as absolute and absolute1 also
we have mentioned the box dimensions
and color.
80px
20px
The div class for the
blue box is nested
in the div class for
yellow box.
Therefore , the blue
box is shifted to left
by 20px with respect
to the yellow box.
Blue box is shifted to left by 20px
with respect to the yellow box
<!DOCTYPE html>
<html>
<head>
<style>
div.absolute {
height: 400px;
width: 400px;
position: relative;
bottom: 0px;
left: 80px;
background-color:yellow;
}
div.absolute1{
position: absolute;
height: 50px;
width: 50px;
bottom: 0px;
left: 30px;
background-color:blue;}
We have created two division classes
named as absolute and absolute1 also
we have mentioned the box dimensions
and color.
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position:
absolute; is positioned relative to the
nearest positioned ancestor (instead
of positioned relative to the viewport,
like fixed):</p>
<div class=“absolute">
<div class=“absolute1">
</div>
</div>
</body>
</html>
Calling of div classes
One is absolute and
other is absolute1.
Ancestral object is RELATIVE
30px
80px
The ancestral object i.e. yellow box
is positioned relative so the blue
box will be positioned acc to the
yellow box(ancestral obj) that
means blue box will shift left by
50px with respect to yellow box and
not the document body or normal
flow of the page.
80px
30px
Ancestral object is RELATIVE
<!DOCTYPE html>
<html>
<head>
<style>
div.absolute {
height: 400px;
width: 400px;
position: relative;
bottom: 0px;
left: 80px;
background-color:yellow;
}
div.absolute1{
position: absolute;
height: 0px;
width: 50px;
bottom: 50px;
left: 0px;
background-color:blue;}
We have created two division classes
named as absolute and absolute1 also
we have mentioned the box dimensions
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position: absolute; is
positioned relative to the nearest positioned
ancestor (instead of positioned relative to the
viewport, like fixed):</p>
<div class=“absolute">
<div class=“absolute1">
</div>
</div>
</body>
</html>
Calling of div classes
One is absolute and
other is absolute1.
80px
80px
The ancestral object i.e. yellow box
is positioned relative so the blue
box will be positioned acc to the
yellow box(ancestral obj) that
means blue box will shift left by 0px
with respect to yellow box and not
the document body or normal flow
of the page.
0px left with respect to
the yellow box.
<!DOCTYPE html>
<html>
<head>
<style>
div.absolute {
height: 400px;
width: 400px;
position: static;
bottom: 0;
left: 80px;
background-color:yellow;
}
div.absolute1{
position: absolute;
height: 50px;
width: 50px;
bottom: 0;
left: 30px;
background-color:blue;}
</style>
</head>
<body>
<h2>position: absolute;</h2>
<p>An element with position:
absolute; is positioned relative to the
nearest positioned ancestor i.e.
STATIC</p>
<div class=“absolute">
<div class=“absolute1">
</div>
</div>
</body>
</html>
Ancestral object is STATIC
We have created two division classes
named as absolute and absolute1 also
we have mentioned the box dimensions
and color.
Calling of div classes
One is absolute and
other is absolute1.
30px
30px
Yellow box is static therefore
It is relative to the normal flow
of the page .
Position of blue box is ABSOLOUTE
so it will be positioned acc to its
ancestor obj(yellow box) . But
yellow box is static so, blue box will
be positioned acc to the document
body i.e. 50px left from the web
page .
Fixed
• An element with position: fixed; is positioned
relative to the viewport, which means it always
stays in the same place even if the page is
scrolled. The top, right, bottom, and left
properties are used to position the element.
• A fixed element does not leave a gap in the page
where it would normally have been located.
<!DOCTYPE html>
<html>
<head>
<style>
div.fixed {
height: 400px;
width: 400px;
position: fixed;
bottom: 0;
right: 0;
left: 80px;
background-color:yellow;
}
div.fixed1{
height: 50px;
width: 50px;
position: fixed;
bottom: 0;
right: 0;
left: 30px;
background-color:blue;}
We have created two division classes
named as fixed and fixed1 also we have
mentioned the box dimensions and
color.
</style>
</head>
<body>
<h2>position: fixed;</h2>
<p>An element with position: fixed;
is positioned relative to the
viewport, which means it always
stays in the same place even if the
page is scrolled:</p>
<div class=“fixed">
</div>
<div class=“fixed1">
</div>
</body>
</html>
Calling of div classes
One is fixed and other is
fixed1.
30px
80px
.
Before the page is scrolled After the page is scrolled
The position of the
object is fixed always
Staticdiv.static {
height: 400px;
width: 400px;
left: 80px;
position: static;
background-color:yellow;
}
div.static1{
height: 50px;
width: 50px;
left: 30px;
position: static;
background-color:blue;
}
Two division
classes are
created
static and
static1
in which box’s
dimensions
and color are
initialized.
<div class="static">
</div>
<div class="static1">
</div>
Calling of two div classes
namely static and static
1
Relative
div.relative {
height: 400px;
width: 400px;
position: relative;
left: 80px;
background-color:yellow;
}
div.relative1{
height: 50px;
width: 50px;
position: relative;
left: 30px;
background-color:blue;
}
<div class=“relative">
</div>
<div class=“relative1">
</div>
Calling of two div
classes namely relative
and relative1
30px
80px
Two division
classes are
created
relative and
relative1
in which box’s
dimensions
and color are
initialized.
Position is static therefore left,right,top,bottom won’t make a difference in the appearance as the object will be
placed acc to the normal flow (top=bottom=left=right=0) of the page
Absolute
div.absolute {
height: 400px;
width: 400px;
position: static;
left: 80px;
background-color:yellow;
}
div.absolute1{
height: 50px;
width: 50px;
position: absolute;
left: 30px;
background-color:blue;
}
<div class=“absolute">
</div>
<div class=“absolute1">
</div>
Calling of two div classes
namely absolute and
absolute1
Two division
classes are
created
absolute and
absolute1
in which box’s
dimensions
and color are
initialized.
30px
As the first obj i.e. yellow box is static so the blue box(absolute) will
uses the document body, and moves along with page scrolling.
div.absolute {
height: 400px;
width: 400px;
position: relative;
left: 80px;
background-color:yellow;
}
div.absolute1{
height: 50px;
width: 50px;
position: absolute;
left: 30px;
background-color:blue;
}
<div class=“absolute">
</div>
<div class=“absolute1">
</div>
Two division
classes are
created
absolute and
absolute1
in which box’s
dimensions
and color are
initialized.
30px
80px
1-Ancestral object is STATIC
2-Ancestral object is RELATIVE
div.fixed {
height: 400px;
width: 400px;
position: fixed;
background-color:yellow;
}
divafixed1{
height: 50px;
width: 50px;
position: fixed;
background-color:blue;
}
Fixed
<div class=“fixed">
</div>
<div class=“fixed1">
</div>
Two division
classes are
created
absolute and
absolute1
in which box’s
dimensions
and color are
initialized.
Calling of two div classes
namely absolute and
absolute1
Before the page is scrolled After the page is scrolled
The position of the
object is fixed always

More Related Content

What's hot

What's hot (20)

Css positioning
Css positioningCss positioning
Css positioning
 
CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Css Display Property
Css Display PropertyCss Display Property
Css Display Property
 
Css Specificity
Css SpecificityCss Specificity
Css Specificity
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations CSS Transitions, Transforms, Animations
CSS Transitions, Transforms, Animations
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Page layout with css
Page layout with cssPage layout with css
Page layout with css
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
Css Basics
Css BasicsCss Basics
Css Basics
 
CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)
 
Understanding flex box CSS Day 2016
Understanding flex box CSS Day 2016Understanding flex box CSS Day 2016
Understanding flex box CSS Day 2016
 
Css
CssCss
Css
 
CSS Layouting #2 : Dimensi & Overflow
CSS Layouting #2 : Dimensi & OverflowCSS Layouting #2 : Dimensi & Overflow
CSS Layouting #2 : Dimensi & Overflow
 
CSS
CSSCSS
CSS
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
 
CSS Dasar #9 : Inheritance
CSS Dasar #9 : InheritanceCSS Dasar #9 : Inheritance
CSS Dasar #9 : Inheritance
 

Similar to CSS Position and it’s values

Web Design Course: CSS lecture 5
Web Design Course: CSS  lecture 5Web Design Course: CSS  lecture 5
Web Design Course: CSS lecture 5Gheyath M. Othman
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)Rafi Haidari
 
Web Design Course: CSS lecture 4
Web Design Course: CSS  lecture 4Web Design Course: CSS  lecture 4
Web Design Course: CSS lecture 4Gheyath M. Othman
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTMLAmit Tyagi
 
CSS for basic learner
CSS for basic learnerCSS for basic learner
CSS for basic learnerYoeung Vibol
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101Ashraf Hamdy
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptxDiyonaVas
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsSenthil Kumar
 
Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elementssanjay2211
 
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...syedfaisal759877
 
Class 3 create an absolute layout with css abs position (aptana)
Class 3  create an absolute layout with css abs position (aptana)Class 3  create an absolute layout with css abs position (aptana)
Class 3 create an absolute layout with css abs position (aptana)Erin M. Kidwell
 

Similar to CSS Position and it’s values (20)

Web Design Course: CSS lecture 5
Web Design Course: CSS  lecture 5Web Design Course: CSS  lecture 5
Web Design Course: CSS lecture 5
 
Css2layout
Css2layoutCss2layout
Css2layout
 
Web Layout
Web LayoutWeb Layout
Web Layout
 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
 
Class 10
Class 10Class 10
Class 10
 
Css 101
Css 101Css 101
Css 101
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
 
Web Design Course: CSS lecture 4
Web Design Course: CSS  lecture 4Web Design Course: CSS  lecture 4
Web Design Course: CSS lecture 4
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
CSS for basic learner
CSS for basic learnerCSS for basic learner
CSS for basic learner
 
Exp13 write up
Exp13 write upExp13 write up
Exp13 write up
 
Lecture-8.pptx
Lecture-8.pptxLecture-8.pptx
Lecture-8.pptx
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Css tips & tricks
Css tips & tricksCss tips & tricks
Css tips & tricks
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elements
 
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
 
Class 3 create an absolute layout with css abs position (aptana)
Class 3  create an absolute layout with css abs position (aptana)Class 3  create an absolute layout with css abs position (aptana)
Class 3 create an absolute layout with css abs position (aptana)
 

Recently uploaded

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

CSS Position and it’s values

  • 1. Position And it’s Values. 80px 30px • Definition: Position property helps in setting the element/object on a desired location of our choice. • In addition to it we can add diff values with it to make it more reliable and attractive. • Diff values are: 80px STATIC RELATIVE FIXED ABSOLUTE 30px 80px 30px
  • 2. 80px 30px STATIC RELATIVE FIXED ABSOLUTE div.static { height: 400px; width: 400px; left: 80px; position: static; background-color:yellow; } div.static1{ height: 50px; width: 50px; left: 30px; position: static; background-color:blue; } div.relative { height: 400px; width: 400px; left: 80px; position: relative; background-color:yellow; } div.relative1{ height: 50px; width: 50px; left: 30px; position: relative; background-color:blue; } div.fixed { height: 400px; width: 400px; left: 80px; position: fixed; bottom: 0; right: 0; background-color:yellow; } div.fixed1{ height: 50px; width: 50px; left: 30px; position: fixed; bottom: 0; right: 0; background-color:blue; } div.absolute{ height: 400px; width: 400px; left: 80px; position: relatiive; background-color:yellow; } div.absolute1{ height: 50px; width: 50px; left: 30px; position: absolute; background-color:blue; } 80px 30px 80px 30px
  • 3. Position Property. The position property specifies the type of positioning method used for an element. Syntax (position: value) • There are four different position values: static : Syntax (position: static); relative : Syntax (position: relative); fixed : Syntax (position: fixed); absolute : Syntax (position: absolute); • Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the position value.
  • 4. Properties And Values Value Description Static Elements renders(in a particular way) in order, as they appear in the document flow. This is default Relative The element is positioned relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position Absolute The element is positioned relative to its first positioned (not static) ancestor element Fixed The element is positioned relative to the browser window Meaning of RENDERS in Hindi : प्रस्तुत करनेवाला OR जो भी डाटा जजस तररके से वेब पेज पे ललखा गया है उसको उसई तररके से प्रस्तुत करने को हम रेंडररिंग कहते है. OR जो भी एललमेंट जजस भी तरह से वेब पेज पे दीखता है उससे रेंडररिंग कहते है Meaning of RENDERS in English: To present in a particular way OR The way that something is performed, written, drawn, etc.
  • 5. Static • HTML elements are positioned static by default. • Static positioned elements are not affected by the top, bottom, left, and right properties . • NORMAL FLOW: When top=bottom=right=left=0px; • An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page. • That means if we initialize left: 10px. It won’t make a difference as the object will be placed acc to the normal flow of the page.
  • 6. <html> <head> <style> div.static { height: 400px; width: 400px; left: 80px; position: static; background-color:yellow; } div.static1{ height: 50px; width: 50px; left: 30px; position: static; background-color:blue; } </style> </head> <body> <h2>position: static;</h2> We have created two division classes named as static and static1 also we have mentioned the box dimensions and color. <p>An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page:</p> <div class="static"> </div> <div class="static1"> </div> </body> </html> Calling of div classes One is static and other is static1.
  • 7. As we have first mentioned the Yellow Box class therefore Yellow Box appears first and then Blue one. This is called as NORMAL FLOW of the page means moving from top to bottom. Static position means that both the Boxes are static with respect to the normal flow of the page(height=width=top=bottom=0) that means whatever is written first in the code will be represented first. The object should be shifted by 10px to left but it didn’t because the position is static so it (obj) will be located acc to the normal flow of the page.
  • 8. Relative • An element with position: relative; is positioned relative to its normal position ( top = bottom = left =right=0). • That means if we initialize left:10px . The object will be shifted by 10px to left with respect to (relative) the normal flow of the page. • Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.
  • 9. <!DOCTYPE html> <html> <head> <style> div.relative { height: 400px; width: 400px; position: relative; left:80px; background-color:yellow; } div.relative1{ height: 50px; width: 50px; position: relative; left:30px; background-color:blue; } We have created two division classes named as relative and relative1 also we have mentioned the box dimensions and color. </style> </head> <body> <h1>position: relative;</h2> <p>An element with position: relative; is positioned relative to its normal position:</p> <div class=“relative"> </div> <div class=“relative1"> </div> </body> </html> Calling of div classes One is relative and other is relative1.
  • 10. Both the boxes are relative with the normal flow of the page. So when we set left:80 and left:30 for yellow and blue box , the blue box got shifted to left by 30px and the yellow box got shifted to left by 80px. 30px 80px
  • 11. Absolute • An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed). • VIEWPORT: The viewport is the user's visible area of a web page. • However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
  • 12. <!DOCTYPE html> <html> <head> <style> div.absolute { height: 400px; width: 400px; position: relative; bottom: 0px; left: 80px; background-color:yellow; } div.absolute1{ position: absolute; height: 50px; width: 50px; bottom: 0px; left: 20px; background-color:blue;} </style> </head> <body> <h2>position: absolute;</h2> <p>An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed):</p> <div class=“absolute"> </div> <div class=“absolute1"> </div> </body> </html> 80px 20px We have created two division classes named as absolute and absolute1 also we have mentioned the box dimensions and color. The div tag for both the boxes are opened and closed separately therefore no effect of absolute position is showcased here
  • 13. 80px 20px As both the boxes have separate opening and closing of div classes so there is no effect of ABSOLUTE position on the blue box. Therefore the blue box is shifted to left by 20px with respect to the document body instead of the yellow box.
  • 14. The correct code.. <!DOCTYPE html> <html> <head> <style> div.absolute { height: 400px; width: 400px; position: relative; bottom: 0px; left: 80px; background-color:yellow; } div.absolute1{ position: absolute; height: 50px; width: 50px; bottom: 0px; left: 20px; background-color:blue;} </style> </head> <body> <h2>position: absolute;</h2> <p>An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed):</p> <div class=“absolute"> <div class=“absolute1"> </div> </div> </body> </html> 80px 20px The div tag for the blue box is nested in the div tag for yellow box . That means the div tag for blue box is inside the div tag of yellow box. We have created two division classes named as absolute and absolute1 also we have mentioned the box dimensions and color.
  • 15. 80px 20px The div class for the blue box is nested in the div class for yellow box. Therefore , the blue box is shifted to left by 20px with respect to the yellow box. Blue box is shifted to left by 20px with respect to the yellow box
  • 16. <!DOCTYPE html> <html> <head> <style> div.absolute { height: 400px; width: 400px; position: relative; bottom: 0px; left: 80px; background-color:yellow; } div.absolute1{ position: absolute; height: 50px; width: 50px; bottom: 0px; left: 30px; background-color:blue;} We have created two division classes named as absolute and absolute1 also we have mentioned the box dimensions and color. </style> </head> <body> <h2>position: absolute;</h2> <p>An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed):</p> <div class=“absolute"> <div class=“absolute1"> </div> </div> </body> </html> Calling of div classes One is absolute and other is absolute1. Ancestral object is RELATIVE 30px 80px
  • 17. The ancestral object i.e. yellow box is positioned relative so the blue box will be positioned acc to the yellow box(ancestral obj) that means blue box will shift left by 50px with respect to yellow box and not the document body or normal flow of the page. 80px 30px
  • 18. Ancestral object is RELATIVE <!DOCTYPE html> <html> <head> <style> div.absolute { height: 400px; width: 400px; position: relative; bottom: 0px; left: 80px; background-color:yellow; } div.absolute1{ position: absolute; height: 0px; width: 50px; bottom: 50px; left: 0px; background-color:blue;} We have created two division classes named as absolute and absolute1 also we have mentioned the box dimensions </style> </head> <body> <h2>position: absolute;</h2> <p>An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed):</p> <div class=“absolute"> <div class=“absolute1"> </div> </div> </body> </html> Calling of div classes One is absolute and other is absolute1. 80px
  • 19. 80px The ancestral object i.e. yellow box is positioned relative so the blue box will be positioned acc to the yellow box(ancestral obj) that means blue box will shift left by 0px with respect to yellow box and not the document body or normal flow of the page. 0px left with respect to the yellow box.
  • 20. <!DOCTYPE html> <html> <head> <style> div.absolute { height: 400px; width: 400px; position: static; bottom: 0; left: 80px; background-color:yellow; } div.absolute1{ position: absolute; height: 50px; width: 50px; bottom: 0; left: 30px; background-color:blue;} </style> </head> <body> <h2>position: absolute;</h2> <p>An element with position: absolute; is positioned relative to the nearest positioned ancestor i.e. STATIC</p> <div class=“absolute"> <div class=“absolute1"> </div> </div> </body> </html> Ancestral object is STATIC We have created two division classes named as absolute and absolute1 also we have mentioned the box dimensions and color. Calling of div classes One is absolute and other is absolute1. 30px
  • 21. 30px Yellow box is static therefore It is relative to the normal flow of the page . Position of blue box is ABSOLOUTE so it will be positioned acc to its ancestor obj(yellow box) . But yellow box is static so, blue box will be positioned acc to the document body i.e. 50px left from the web page .
  • 22. Fixed • An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. • A fixed element does not leave a gap in the page where it would normally have been located.
  • 23. <!DOCTYPE html> <html> <head> <style> div.fixed { height: 400px; width: 400px; position: fixed; bottom: 0; right: 0; left: 80px; background-color:yellow; } div.fixed1{ height: 50px; width: 50px; position: fixed; bottom: 0; right: 0; left: 30px; background-color:blue;} We have created two division classes named as fixed and fixed1 also we have mentioned the box dimensions and color. </style> </head> <body> <h2>position: fixed;</h2> <p>An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled:</p> <div class=“fixed"> </div> <div class=“fixed1"> </div> </body> </html> Calling of div classes One is fixed and other is fixed1. 30px 80px
  • 24. . Before the page is scrolled After the page is scrolled The position of the object is fixed always
  • 25. Staticdiv.static { height: 400px; width: 400px; left: 80px; position: static; background-color:yellow; } div.static1{ height: 50px; width: 50px; left: 30px; position: static; background-color:blue; } Two division classes are created static and static1 in which box’s dimensions and color are initialized. <div class="static"> </div> <div class="static1"> </div> Calling of two div classes namely static and static 1 Relative div.relative { height: 400px; width: 400px; position: relative; left: 80px; background-color:yellow; } div.relative1{ height: 50px; width: 50px; position: relative; left: 30px; background-color:blue; } <div class=“relative"> </div> <div class=“relative1"> </div> Calling of two div classes namely relative and relative1 30px 80px Two division classes are created relative and relative1 in which box’s dimensions and color are initialized. Position is static therefore left,right,top,bottom won’t make a difference in the appearance as the object will be placed acc to the normal flow (top=bottom=left=right=0) of the page
  • 26. Absolute div.absolute { height: 400px; width: 400px; position: static; left: 80px; background-color:yellow; } div.absolute1{ height: 50px; width: 50px; position: absolute; left: 30px; background-color:blue; } <div class=“absolute"> </div> <div class=“absolute1"> </div> Calling of two div classes namely absolute and absolute1 Two division classes are created absolute and absolute1 in which box’s dimensions and color are initialized. 30px As the first obj i.e. yellow box is static so the blue box(absolute) will uses the document body, and moves along with page scrolling. div.absolute { height: 400px; width: 400px; position: relative; left: 80px; background-color:yellow; } div.absolute1{ height: 50px; width: 50px; position: absolute; left: 30px; background-color:blue; } <div class=“absolute"> </div> <div class=“absolute1"> </div> Two division classes are created absolute and absolute1 in which box’s dimensions and color are initialized. 30px 80px 1-Ancestral object is STATIC 2-Ancestral object is RELATIVE
  • 27. div.fixed { height: 400px; width: 400px; position: fixed; background-color:yellow; } divafixed1{ height: 50px; width: 50px; position: fixed; background-color:blue; } Fixed <div class=“fixed"> </div> <div class=“fixed1"> </div> Two division classes are created absolute and absolute1 in which box’s dimensions and color are initialized. Calling of two div classes namely absolute and absolute1 Before the page is scrolled After the page is scrolled The position of the object is fixed always