[CSS]CSS Advanced - CSS Positioning
개발관련/CSS/CSS3 2012. 10. 23. 22:27 |출처: http://www.w3schools.com/css/css_positioning.asp
There are four different positioning methods.
1. 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 properties.
2. Fixed Positioning
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 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.
3. Relative Positioning
A relative positioned element is positioned relative to its normal position.
Example
{
position:relative;
left:-20px;
}
h2.pos_right
{
position:relative;
left:20px;
}
Try it yourself »
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.
4. 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>:
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.
All CSS Positioning Properties
The number in the "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).
Property | Description | Values | CSS |
---|---|---|---|
bottom | Sets the bottom margin edge for a positioned box | auto length % inherit | 2 |
clip | Clips an absolutely positioned element | shape auto inherit | 2 |
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 | 2 |
left | Sets the left margin edge for a positioned box | auto length % inherit | 2 |
overflow | Specifies what happens if content overflows an element's box | auto hidden scroll visible inherit | 2 |
position | Specifies the type of positioning for an element | absolute fixed relative static inherit | 2 |
right | Sets the right margin edge for a positioned box | auto length % inherit | 2 |
top | Sets the top margin edge for a positioned box | auto length % inherit | 2 |
z-index | Sets the stack order of an element | number auto inherit | 2 |
CSS Positioning
Position an element relative to the browser window
Position an element relative to its normal position
Position an element with an absolute value
Overlapping elements
Set the shape of an element
How to create a scroll bar when an element's content is too big to fit
How to set the browser to automatically handle overflow
Set the top edge of an image using a pixel value
Set the bottom edge of an image using a pixel value
Set the left edge of an image using a pixel value
Set the right edge of an image using a pixel value
Change the cursor
'개발관련 > CSS/CSS3' 카테고리의 다른 글
[CSS]CSS Advanced - CSS Aligning Elements (0) | 2012.10.24 |
---|---|
[CSS]CSS Advanced - CSS Floating (0) | 2012.10.23 |
[CSS]CSS Advanced - CSS Display (0) | 2012.10.23 |
[CSS]CSS Advanced - CSS Dimension (0) | 2012.10.23 |
[CSS]CSS Advanced - CSS Grouping and Nesting (0) | 2012.10.23 |