This link has been bookmarked by 234 people . It was first bookmarked on 03 Aug 2006, by someone privately.
-
13 Feb 20
-
The
positionproperty specifies the type of positioning method used for an element (static, relative, fixed, absolute or sticky). -
staticrelativefixedabsolutesticky
There are five different position values:
-
Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the
positionproperty is set first. They also work differently depending on the position value. -
position: static;
HTML elements are positioned static by default.
Static positioned elements are not affected by the top, bottom, left, and right properties.
An element with
position: static;is not positioned in any special way; it is always positioned according to the normal flow of the page: -
position: relative;
An element with
position: relative;is positioned relative to its normal position.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.
-
position: 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. -
position: absolute;
An element with
position: absolute;is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed). -
position: sticky;
An element with
position: sticky;is positioned based on the user's scroll position.
-
-
08 Sep 19
-
HTML elements are positioned static by default.
-
An element with
position: static;is not positioned in any special way; it is always positioned according to the normal flow of the page:
-
-
13 Jun 18
-
19 Mar 17
-
Overlapping Elements
-
-
27 Feb 17
"CSS Layout - The position Property
The position property specifies the type of positioning method used for an element (static, relative, fixed or absolute).
The position Property
The position property specifies the type of positioning method used for an element.
There are four different position values:
static
relative
fixed
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.
position: static;
HTML elements are positioned static by default.
Static positioned elements are not affected by the top, bottom, left, and right properties.
An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page:
This <div> element has position: static;
Here is the CSS that is used:
Example
div.static {
position: static;
border: 3px solid #73AD21;
}
position: relative;
An element with position: relative; is positioned relative to its normal position.
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.
This <div> element has position: relative;
Here is the CSS that is used:
Example
div.relative {
position: relative;
left: 30px;
border: 3px solid #73AD21;
}
position: 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.
Notice the fixed element in the lower-right corner of the page. Here is the CSS that is used:
Example
div.fixed {
position: fixed;
bottom: 0;
right: 0;
width: 300px;
border: 3px solid #73AD21;
}
This <div> element has position: fixed;
position: absolute;
An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
Note: A "positioned" element is one whose position is anything except static.
Here is a simple example:
This <div> element has position: relative;
This <div> element has position: absolute;
Here is the CSS that is used:
Example
div.relative {
position: relative;
width: 400px;
height: 200px;
border: 3px solid #73AD21;
}
div.absolute {
position: absolute;
top: 80px;
right: 0;
width: 200px;
height: 100px;
border: 3px solid #73AD21;
}
Overlapping Elements
When elements are positioned, they can overlap other elements.
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
An element can have a positive or negative stack order:
This is a heading
Because the image has a z-index of -1, it will be placed behind the text.
Example
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
An element with greater stack order is always in front of an element with a lower stack order.
Note: If two positioned elements overlap without a z-index specified, the element positioned last in the HTML code will be shown on top.
Positioning Text In an Image
How to position text over an image:
Example
Norway
Bottom Left
Top Left
Top Right
Bottom Right
Centered
Try it Yourself:
More Examples
Set the shape of an element
This example demonstrates how to set the shape of an element. The element is clipped into this shape, and displayed.
How to show overflow in an element using scroll
This example demonstrates how to set the overflow property to create a scroll bar when an element's content is too big to fit in a specified area.
How to set the browser to automatically handle overflow
This example demonstrates how to set the browser to automatically handle overflow.
Change the cursor
This example demonstrates how to change the cursor.
Test Yourself with Exercises!
All CSS Positioning Properties
Property Description
bottom Sets the bottom margin edge for a positioned box
clip Clips an absolutely positioned element
cursor Specifies the type of cursor to be displayed
left Sets the left margin edge for a positioned box
overflow Specifies what happens if content overflows an element's box
overflow-x Specifies what to do with the left/right edges of the content if it overflows the element's content area
overflow-y Specifies what to do with the top/bottom edges of the content if it overflows the element's content area
position Specifies the type of positioning for an element
right Sets the right margin edge for a positioned box
top Sets the top margin edge for a positioned box
z-index Sets the stack order of an element" -
02 Oct 16
-
22 Sep 16
-
property specifies the type of positioning method used for an element
-
positioned
-
-
10 Jul 16
-
02 May 16
-
it is always positioned according to the normal flow of the page:
-
is positioned relative to the viewport
-
An element with
position: absolute;is positioned relative to the nearest positioned ancestor
-
-
14 Apr 16
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
-
width: 200px;
height: 100px; -
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
s positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
-
10 Apr 16
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
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.
-
An element with
position: fixed;is positioned relative to the viewport -
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. -
An element with
position: absolute;is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
-
-
21 Mar 16
-
19 Mar 16
-
07 Mar 16
-
Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the
positionproperty is set first. They also work differently depending on the position value. -
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
Other content will not be adjusted to fit into any gap left by the element.
-
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
-
An element with
position: absolute;is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed). -
However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
-
The
z-indexproperty specifies the stack order of an element (which element should be placed in front of, or behind, the others). -
An element with greater stack order is always in front of an element with a lower stack order.
-
-
09 Feb 16
-
02 Nov 15
-
position: relative;
-
position: 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.
-
position: absolute;
An element with
position: absolute;is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
Note: A "positioned" element is one whose position is anything except
static.
-
-
06 Oct 15
-
04 Oct 15
-
top, bottom, left, and right properties
-
these properties will not work unless the
positionproperty is set firs -
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
n element with
position: relative;is positioned relative to its normal positio -
Other content will not be adjusted to fit into any gap left by the element
-
always stays in the same place even if the page is scrolled
-
relative to the viewport
-
positioned relative to the nearest positioned ancesto
-
o positioned ancestors, it uses the document body
-
pecifies the stack order of an element
-
An element with greater stack order is always in front of an element with a lower stack order
-
-
27 Aug 15
-
Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the
positionproperty is set first. They also work differently depending on the position value.
-
-
05 Aug 15
-
14 Jul 15
-
Positioning
-
-
29 Jun 15
-
20 Apr 15
-
It can also place an element behind another,
-
-
11 Apr 15
-
07 Apr 15
-
positioned relative to the first parent element that has a position other than static.
-
An element with greater stack order is always in front of an element with a lower stack order.
-
-
14 Mar 15
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>
-
An element with greater stack order is always in front of an element with a lower stack order.
-
Note: If two positioned elements overlap without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
29 Jan 15
-
overlap other elements.
-
-
24 Nov 14
-
The CSS positioning properties allow you to position an element
-
four different positioning methods.
-
Fixed positioned elements are removed from the normal flow
-
-
22 Nov 14
-
The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big.
-
-
20 Nov 14
-
13 Nov 14
-
according to the normal flow of the page.
-
browser window
-
top, bottom, left, and right properties
-
position: fixed
-
by default.
-
Static positioned elements
-
not affected by
-
normal flow of the page
-
its normal position
-
from its normal position
-
reserved space
-
first parent element
-
removed from the normal flow
-
overlap other elements.
-
positioned outside the normal flow
-
z-index
-
-
12 Nov 14
-
07 Nov 14
-
An absolute position element is positioned relative to the first parent element that has a position other than static
-
-
15 Oct 14
-
03 Oct 14
-
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled:
-
Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.
Fixed positioned elements can overlap other elements.
-
The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static.
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
-
-
04 Sep 14
-
Elements can be 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 positioning method.
-
are positioned static by default
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
It will not move even if the window is scrolled
-
Fixed positioned elements can overlap other elements.
-
is positioned relative to its normal position
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
Absolutely positioned elements can overlap other elements.
-
z-index property specifies the stack order of an element
-
An element with greater stack order is always in front of an element with a lower stack order.
-
How to show overflow in an element using scroll
-
Change the cursor
-
cursor Specifies the type of cursor to be displayed -
overflow
Specifies what happens if content overflows an element's box -
position Specifies the type of positioning for an element
-
-
16 Mar 14
-
Note: If two positioned elements overlap without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
07 Feb 14
-
Fixed positioned elements can overlap other elements.
-
-
15 Jan 14
-
top, bottom, left, and right properties
-
position property is set first
-
-
25 Nov 13
-
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled:
-
A relative positioned element is positioned relative to its normal position.
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
-
12 Nov 13
-
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;
} -
ositioning Properties
-
-
25 Oct 13
-
30 Sep 13
-
27 Sep 13
-
15 Sep 13
-
A static positioned element is always positioned according to the normal flow of the page.
-
-
20 Jul 13
-
17 Jul 13
-
Static positioned elements are not affected by the top, bottom, left, and right properties
-
positioned relative to the browser window.
-
positioned relative to its normal position.
-
but the reserved space for the element is still preserved in the normal flow.
-
is positioned relative to the first parent element that has a position other than static
-
Note: If two positioned elements overlap, without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
29 May 13
-
Positioning
-
Elements can be 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 positioning method.
-
-
08 Apr 13
-
A static positioned element is always positioned according to the normal flow of the page.
-
-
20 Mar 13
-
18 Mar 13
-
20 Feb 13
-
can also place an element behind another
-
allow you to position an element
-
specify what should happen when an element's content is too big
-
positioned using the top, bottom, left, and right properties
-
will not work unless the position property is set first
-
work differently depending on the positioning method
-
static by default
-
not affected by the top, bottom, left, and right properties
-
fixed position is positioned relative to the browser window
-
will not move even if the window is scrolled
-
removed from the normal flow
-
can overlap other elements
-
relative positioned element is positioned relative to its normal position
-
can be moved and overlap other elements
-
reserved space for the element is still preserved in the normal flow
-
often used as container blocks for absolutely positioned elements
-
absolute position element is positioned relative to the first parent element that has a position other than static
-
removed from the normal flow
-
other elements behave like the absolutely positioned element does not exist
-
can overlap other elements
-
When elements are positioned outside the normal flow
-
z-index property specifies the stack order of an element
-
-
25 Jan 13
-
It can also place an element behind another
-
unless
-
-
17 Dec 12
-
However, these properties will not work unless the position property is set first.
-
Elements can be positioned using the top, bottom, left, and right properties
-
positioned static by default
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
positioned relative to the browser window
-
positioned relative to its normal position
-
z-index property specifies the stack order of an element
-
-
08 Dec 12
-
07 Dec 12
-
The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big.
-
Elements can be 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 positioning method.
-
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled:
-
Note: IE7 and IE8 support the fixed value only if a !DOCTYPE is specified.
-
Fixed positioned elements can overlap other elements.
-
A relative positioned element is positioned relative to its normal position.
-
The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
Absolutely positioned elements can overlap other elements.
-
An element with greater stack order is always in front of an element with a lower stack order.
-
Note: If two positioned elements overlap, without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
31 Oct 12
-
27 Aug 12
-
default
-
A static positioned element is always positioned according to the normal flow of the page.
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
positioned relative to the browser window.
-
It will not move even if the window is scrolled:
-
The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
-
19 Jul 12
-
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
-
normal flow of the
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
Fixed Positioning
-
It will not move even if the window is scrolled:
-
Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.
-
Fixed positioned elements can overlap other elements.
-
relative to its normal position
-
can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
-
When elements are positioned outside the normal flow, they can overlap other elements.
-
z-index
-
An element can have a positive or negative stack order:
-
If two positioned elements overlap, without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
27 Jun 12
-
CSS Pseudo-element
CSS Navigation Bar
CSS Image Gallery
CSS Image Opacity
CSS Image Sprites
CSS Media Types
CSS Attribute Selectors
CSS Summary
CSS Examples
CSS Examples
CSS Quiz
CSS Quiz
CSS Certificate
CSS References
CSS Reference
CSS Selectors
CSS Reference Aural
CSS Web Safe Fonts
CSS Units
CSS Colors
CSS Color Values
CSS Color Names
CSS Color HEXCSS Positioning
Positioning can be tricky sometimes!
Decide which element to display in front!
Elements can overlap!
Positioning
The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big.
Elements can be 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 positioning method.
There are four different positioning methods.
Static Positioning
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
Static positioned elements are not affected by the top, bottom, left, and right
-
-
18 Jun 12
-
11 Jun 12
-
normal flow of the page.
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
relative to the browser window.
-
It will not move even if the window is scrolled
-
relative to its normal position.
-
reserved space for the element is still preserved in the normal flow.
-
first parent element that has a position other than static.
-
If no such element is found, the containing block is <html>:
-
emoved from the normal flow
-
behave like the absolutely positioned element does not exist.
-
outside the normal flow, they can overlap other elements.
-
the element positioned last in the HTML code will be shown on top.
-
-
31 May 12
-
The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
-
05 May 12
-
03 May 12
-
01 May 12
-
03 Mar 12
-
24 Feb 12
-
18 Feb 12
-
Elements can be positioned using the top, bottom, left, and right properties
-
A static positioned element is always positioned according to the normal flow of the page.
-
An element with fixed position is positioned relative to the browser window.
-
It will not move even if the window is scrolled
-
Absolutely positioned elements are removed from the normal flow
-
z-index property specifies the stack order of an element
-
positive or negative
-
An element with greater stack order is always in front of an element with a lower stack order.
-
-
04 Oct 11
-
Change the cursor
-
-
20 Sep 11
-
19 Jul 11
-
Elements can be 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 positioning method.
-
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled:
-
A relative positioned element
-
When elements are positioned outside the normal flow, they can overlap other elements.
-
All CSS Positioning Propertie
-
-
12 Jun 11
-
It will not move even if the window is scrolled:
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>
-
Absolutely positioned elements can overlap other elements.
-
-
15 May 11
-
using the top, bottom, left, and right properties
-
Property Description Values CSS bottom Sets the bottom margin edge for a positioned box auto
length
%
inherit2 clip Clips an absolutely positioned element shape
auto
inherit2 cursor Specifies the type of cursor to be displayed url
auto
crosshair
default
pointer
move
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
text
wait
help2 left Sets the left margin edge for a positioned box auto
length
%
inherit2 overflow Specifies what happens if content overflows an element's box auto
hidden
scroll
visible
inherit2 position Specifies the type of positioning for an element absolute
fixed
relative
static
inherit2 right Sets the right margin edge for a positioned box auto
length
%
inherit2 top Sets the top margin edge for a positioned box auto
length
%
inherit2 z-index Sets the stack order of an element number
auto
inherit2 -
four different positioning methods
-
position:fixed;
-
position:relative;
-
to the first parent element t
-
z-index property
-
-
14 May 11
-
However, these properties will not work unless the position property is set first.
-
Elements can be positioned using the top, bottom, left, and right properties
-
There are four different positioning methods.
-
An element with fixed position is positioned relative to the browser window.
-
A relative positioned element is positioned relative to its normal position.
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
-
Absolutely positioned elements can overlap other elements.
-
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
-
An element with greater stack order is always in front of an element with a lower stack order.
-
-
16 Mar 11
-
25 Feb 11
-
The CSS positioning properties allow you to position an element.
-
Elements can be positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first.
-
There are four different positioning methods.
-
HTML elements are positioned static by default.
-
Static positioned elements are not affected by the top, bottom, left, and right properties.
-
An element with fixed position is positioned relative to the browser window.
-
A relative positioned element is positioned relative to its normal position.
-
The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
Relatively positioned elements are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
-
Absolutely positioned elements can overlap other elements
-
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others)
-
An element with greater stack order is always in front of an element with a lower stack order.
-
Note: If two positioned elements overlap, without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
03 Feb 11
-
11 Jan 11
-
03 Jan 11
-
30 Dec 10
-
Fixed Positioning
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled:
Example
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;
}
Try it yourself »Note: Internet Explorer supports the fixed value only if a !DOCTYPE is specified.
Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.
-
Fixed positioned elements can overlap other elements.
-
Relative Positioning
A relative positioned element is positioned relative to its normal position.
Example
h2.pos_left
{
position:relative;
left:-20px;
}
h2.pos_right
{
position:relative;
left:20px;
}
Try it yourself »The content of a relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
Absolute Positioning
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
Example
h2
{
position:absolute;
left:100px;
top:150px;
}
Try it yourself »Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
-
Absolutely positioned elements can overlap other elements.
-
Overlapping Elements
When elements are positioned outside the normal flow, they can overlap other elements.
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
An element can have a positive or negative stack order:
Example
img
{
position:absolute;
left:0px;
top:0px;
z-index:-1
}
Try it yourself »An element with greater stack order is always in front of an element with a lower stack order.
-
Note: If two positioned elements overlap, without a z-index specified, the element positioned last in the HTML code will be shown on top.
-
-
17 Nov 10
-
12 Oct 10
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
Absolutely positioned elements can overlap other elements.
-
-
27 Sep 10
-
21 Sep 10
-
elements are positioned static by default
-
positioned relative to its normal position.
-
content of a relatively positioned elements can be moved and overlap other elements
-
absolute position element is positioned relative to the first parent element
-
z-index property specifies the stack order of an element
-
-
23 Aug 10
-
12 Aug 10
-
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
-
An element with fixed position is positioned relative to the browser window.
-
Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.
-
Relative Positioning
A relative positioned element is positioned relative to its normal position.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
-
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.
-
he z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
-
cursor Specifies the type of cursor to be displayed url
auto
crosshair
default
pointer
move
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
text
wait
help -
overflow
Specifies what happens if content overflows an element's box auto
hidden
scroll
visible
inherit -
-
-
-
03 Jun 10
-
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;
}
-
-
25 Apr 10
-
13 Mar 10
-
HTML elements are positioned static by default.
-
An absolute position element is positioned relative to the first parent element that has a position other than static.
-
-
06 Mar 10
-
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
-
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled:
-
Internet Explorer supports the fixed value only if a !DOCTYPE is specified.
-
Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.
-
A relative positioned element is positioned relative to its normal position.
-
The content of a relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
-
Relatively positioned element are often used as container blocks for absolutely positioned elements.
-
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>
-
Absolutely positioned elements are removed from the normal flow.
-
When elements are positioned outside the normal flow, they can overlap other elements.
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
-
-
13 Jan 10
-
12 Sep 09
-
10 May 09
-
03 Feb 09
-
04 Apr 08
-
01 Feb 08
Marcelo Stein de Lima SousaFree HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
-
08 Jan 08
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.