SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 
5.1 css box model
5.1 css box model5.1 css box model
5.1 css box modelBulldogs83
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid LayoutRachel Andrew
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overviewJacob Nelson
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOMMindy McAdams
 
Media queries A to Z
Media queries A to ZMedia queries A to Z
Media queries A to ZShameem Reza
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS PresentationShawn Calvert
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation Salman Memon
 
Basic HTML
Basic HTMLBasic HTML
Basic HTMLSayan De
 
Basic Html Notes
Basic Html NotesBasic Html Notes
Basic Html NotesNextGenr
 
HTML Semantic Elements
HTML Semantic ElementsHTML Semantic Elements
HTML Semantic ElementsReema
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Chris Poteet
 
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)Webtech Learning
 

Mais procurados (20)

How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
5.1 css box model
5.1 css box model5.1 css box model
5.1 css box model
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
 
Media queries A to Z
Media queries A to ZMedia queries A to Z
Media queries A to Z
 
Dom
DomDom
Dom
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
jQuery
jQueryjQuery
jQuery
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Basic HTML
Basic HTMLBasic HTML
Basic HTML
 
Basic Html Notes
Basic Html NotesBasic Html Notes
Basic Html Notes
 
HTML Semantic Elements
HTML Semantic ElementsHTML Semantic Elements
HTML Semantic Elements
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
 
Javascript
JavascriptJavascript
Javascript
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Css positioning
Css positioningCss positioning
Css positioning
 
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)
 

Semelhante a CSS Position and it’s values

Semelhante a 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
 
CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3
 
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. ...
 

Último

2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf203318pmpc
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 

Último (20)

2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 

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