Web Development

Position

Specifies the type of position method used for an element.

Type

static Default value. Elements render in order, as they appear in the document flow and is not positioned in a special way. If no method is defined, position uses static. A static element is said to be not positioned and an element with its position set to anything else is said to be positioned.
absolute The element is positioned relative to the nearest positioned ancestor. If not ancestors are found, the element uses the body tag.
fixed The element is positioned relative to the browser window. Meaning that the element stays at the top when you scroll.
relative The element is positioned relative to its normal position, so “left:20px” adds 20 pixels to the element’s LEFT position
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Clear

The clear property specifies on which sides of an element floating elements are not allowed to float.

Default value: none;

Inherited: no;

Margin

Is used to generate space around elements. To shorten the code just use margin (top, right, bottom, left). Example: margin: 10px 20px 10 px 20px;

3 values

margin: 25px 50px 75px; (top, right and left, bottom)

If the margin property has 2 values:

margin: 25px 50px; (top and bottom, right and left)

inherit – specifies that the margin should be inherited from the parent element

You can set the margin property to auto to horizontally center the element within its container. The element will then take up the specified width, and the remaining space will be split equally between the left and right margins.

This example lets the left margin be inherited from the parent element. E.g., a <p> element nested within a <div> element. The <div> element is parent and the <p> element is the child.

Skriv et svar