Positioning Flashcards
How does position: relative affect an element.
Position: relative allows an element to be positioned RELATIVE to its natural location in the flow of the document. It does not remove the element from flow, therefore other elements do not move into its space.
Name the default layout for elements in CSS.
“Flow” is the default layout for elements, in which elements are arranged to avoid overlap.
What is the primary concern with position: absolute effect on layout.
Position: absolute pulls the element out of flow, and so can obscure other elements due to its position (either natural position or dictated position).
Does padding affect position: absolute elements?
No, padding only affects in-flow elements and will not affect position: absolute elements.
What is the default position for a position: absolute element?
The default position, the position without any addition top, left, bottom, right settings is its natural flow location
What values can be used to set the position of an element using position: in CSS
Position can be set with:
px
%
rem
em
Name two reasons to set position: relative on an element.
1) It allows the constraint of certain child-elements.
2) It allows other CSS properties to be used.
How is the location of an absolutely positioned element calculated?
The position is calculated in relation to its nearest POSITIONED ancestor. If it does not find one, it is positioned in relation to the “initial containing block”
What potential affect does position: absolute have on its wrapper or container?
By taking the absolutely positioned element out of flow, we can have the wrapper or container collapse to zero height.
Name the various Position choices in CSS.
“Static” - which is default position.
“Relative”, “Absolute”, “Fixed” and “Sticky”
How does position: absolute affect an element?
position: absolute takes the element out of the normal flow, and bases its new position on whatever is constraining it (its container or wrapper)
How do we “opt-out” an element from positioned layout.
We set an element’s position to either:
“static” or “initial” to opt-out of positioned layout.
Can position: relative be applied to both in-line and block elements
Yes, position: relative will affect both in-line and block elements
How does setting position: relative affect other nearby elements.
position: relative does not affect other nearby elements, they continue to act as if the element was in flow (position: static) allowing (or causing) elements to potentially overlap.
Give the parameters for using the Centering Trick with position: absolute
The centering trick is “invoked” with:
1) position: absolute;
2) All cardinal positions set to 0px;
3) A defined Width: and Height:
4) Margins: auto