CSS (seven) positioning

Locate

A positioning attribute) element

Element attributes include positioning a positioning mode and a two offset edge portions.

1. Edge Bias

top, bottom, left, right, they are the respective positions of the parent element from the edge.

Of course, you can only use two of them, such as top, left.

2. Positioning mode

In CSS, position attribute is used to define the elements of the positioning mode, the syntax: position: static | relative | absolute | fixed

1) static positioning (static)

Static positioning is the default way to locate all the elements, is the default position of each element in the html document flow. In fact, the standard flow characteristics.

2) the relative positioning (relative)

To move his upper left corner as the reference point. Does not move off the mark.

3) Absolute positioning (absolute)

Absolute positioning with floating, like, does not occupy the position.

When the parent element without positioning: datum point: the current screen, nothing to do with the parent element.

When the parent element positioning: According to recently has been positioned parent element (absolute, fixed or relative) of the parent element (grandfather) for positioning.

Note: Add the cassette positioning and floating margin: 0 auto; fail. At this time, how to make a box centered it?

margin-left half of his 50% then: absolute positioning left

4) fixedly positioned (fixed)

Fixed positioning is a special form of absolute positioning it to the browser window to define page elements as a reference.

Note: Like the floating element adds absolutely positioned and fixed positioning, the elements will be converted to a row within the block.

Ii) stacking order (z-index)

When a plurality of positioning elements at the same time, the overlap may occur between the positioning elements.

Want to be adjusted in the stacking order of overlapping elements CSS may be used z-index.

The greater the value of the above.

 

Guess you like

Origin www.cnblogs.com/Shadowplay/p/11013777.html