| position | The position property specifies the type of positioning method used for an element. | |||||||||||||||||||
| Elements are then positioned using the top, bottom, left, and right properties. | ||||||||||||||||||||
| top: | Sets the top margin edge for a positioned box | However, these properties will not work unless the position property is set first. They also work differently depending on the position value. | ||||||||||||||||||
| right: | Sets the right margin edge for a positioned box | |||||||||||||||||||
| bottom: | Sets the bottom margin edge for a positioned box | An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page | ||||||||||||||||||
| left: | Sets the left margin edge for a positioned box | 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. | ||||||||||||||||||||
| clip: | rect(0px,60px,200px,0px); | Clips an absolutely positioned 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. | |||||||||||||||||
| cursor: | crosshair; | Specifies the type of cursor to be displayed | A fixed element does not leave a gap in the page where it would normally have been located. | |||||||||||||||||
| help; | An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed). | |||||||||||||||||||
| wait; | However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling. | |||||||||||||||||||
| overflow: | scroll; | Note: A "positioned" element is one whose position is anything except static. | ||||||||||||||||||
| overflow-x: | scroll; | |||||||||||||||||||
| overflow-y: | scroll; | Overlapping Elements | ||||||||||||||||||
| position: | static; | default | Specifies what happens if content overflows an element's box | When elements are positioned, they can overlap other elements. | ||||||||||||||||
| relative; | Specifies what to do with the left/right edges of the content if it overflows the element's content area | The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others). | ||||||||||||||||||
| fixed; | Specifies what to do with the top/bottom edges of the content if it overflows the element's content area | An element can have a positive or negative stack order: | ||||||||||||||||||
| absolute; | Specifies the type of positioning for an element | 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. | ||||||||||||||||||||
| z-index: | -1; | Sets the stack order of an element | ||||||||||||||||||
| 0; | <head> | |||||||||||||||||||
| 1; | <style> | |||||||||||||||||||
| 3; | img { | |||||||||||||||||||
| auto; | default | position: absolute; | ||||||||||||||||||
| left: 0px; | ||||||||||||||||||||
| top: 0px; | ||||||||||||||||||||
| width: | z-index: -1; | |||||||||||||||||||
| height: | } | |||||||||||||||||||
| </style> | ||||||||||||||||||||
| min-width: | </head> | |||||||||||||||||||
| min-height: | <body> | |||||||||||||||||||
| <h1>This is a heading</h1> | ||||||||||||||||||||
| max-width: | <img src="w3css.gif" width="100" height="140"> | |||||||||||||||||||
| max-height: | <p>Because the image has a z-index of -1, it will be placed behind the text.</p> | |||||||||||||||||||
| </body> | ||||||||||||||||||||
| Float | The float property specifies whether or not an element should float. | the float property can be used to wrap text around images | ||||||||||||||||||
| float: | none; | default | The element is not floated, and will be displayed just where it occurs in the text. This is default | The following example specifies that an image should float to the right in a text: | ||||||||||||||||
| left; | The element floats to the left | <head> | ||||||||||||||||||
| right; | The element floats the right | <style> | ||||||||||||||||||
| initial | Sets this property to its default value | img { | ||||||||||||||||||
| inherit | Inherits this property from its parent element | float: left; | ||||||||||||||||||
| margin: 0px 10px -25px 20px; | Short-cut > top - right - bottom - left | |||||||||||||||||||
| } | ||||||||||||||||||||
| clear: | left; | The clear property is used to control the behavior of floating elements. | </style> | |||||||||||||||||
| right; | </head> | |||||||||||||||||||
| <body> | ||||||||||||||||||||
| <p><img src="w3css.gif" alt="W3Schools.com" width="80" height="90"> In this example, the image will float to the left in the paragraph, and the text in the paragraph will wrap around the image…..</p> | ||||||||||||||||||||
| none; | </body> | |||||||||||||||||||
| left; | ||||||||||||||||||||
| right; | ||||||||||||||||||||
| both; | ||||||||||||||||||||
| none; | ||||||||||||||||||||
| overflow: | auto; | |||||||||||||||||||