Positioning Flashcards

1
Q

How does position: relative affect an element.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name the default layout for elements in CSS.

A

“Flow” is the default layout for elements, in which elements are arranged to avoid overlap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the primary concern with position: absolute effect on layout.

A

Position: absolute pulls the element out of flow, and so can obscure other elements due to its position (either natural position or dictated position).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Does padding affect position: absolute elements?

A

No, padding only affects in-flow elements and will not affect position: absolute elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the default position for a position: absolute element?

A

The default position, the position without any addition top, left, bottom, right settings is its natural flow location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What values can be used to set the position of an element using position: in CSS

A

Position can be set with:
px
%
rem
em

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Name two reasons to set position: relative on an element.

A

1) It allows the constraint of certain child-elements.
2) It allows other CSS properties to be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How is the location of an absolutely positioned element calculated?

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What potential affect does position: absolute have on its wrapper or container?

A

By taking the absolutely positioned element out of flow, we can have the wrapper or container collapse to zero height.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Name the various Position choices in CSS.

A

“Static” - which is default position.
“Relative”, “Absolute”, “Fixed” and “Sticky”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does position: absolute affect an element?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do we “opt-out” an element from positioned layout.

A

We set an element’s position to either:
“static” or “initial” to opt-out of positioned layout.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can position: relative be applied to both in-line and block elements

A

Yes, position: relative will affect both in-line and block elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does setting position: relative affect other nearby elements.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give the parameters for using the Centering Trick with position: absolute

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If we want to move items around interactively with JavaScript, what might we use in our CSS?

A

We might use transform: translate to move elements around using CSS.

17
Q

If we set top:0 and bottom: 0 on a fixed or absolutely positioned element, what do we achieve?

A

We cause the element to stretch from the top to the bottom of the containing element

18
Q

What is another way to think of position: relative?

A

That position: relative is actually relative to itself (and not to anything else).

19
Q

What subtle things happens when we set an element to position: relative?

A

It gains the ability to be positioned with a z-axis delcaration.

20
Q

Are static elements able to be positioned with a z-index?

A

No, static elements cannot have a z-index.

21
Q

Where is a position: fixed element placed in relation to?

A

A position: fixed element is placed in relation to the viewport.

22
Q

What is a potential concern with position: fixed elements?

A

That they may overlap other elements during scrolling, potentially making either of the elements inaccessible

23
Q

With a fixed header that links to an anchor on the same page, how might we avoid inaccessibility issues based on the header?

A

We might add a

scroll-margin-top: size

declaration to avoid having the anchor under the header

24
Q

What is an element’s “snap area”?

A

snap area is a box that defines where an element will be snapped to

25
Q

How do we use place-items property?

A

place-items replaces align-items and justify-items (in that order)

place-items: center center;

26
Q

When should we use margin instead of padding?

A
  1. When we want elements to overlap
  2. When we need space around elements
  3. When we need to center something
  4. When we want to push an element around
  5. Prevent elements from touching
27
Q

What is a basic rule of thumb as to when to use Margin?

A

When we want to space an element in relation to other elements on the page.

28
Q

What is a basic rule of thumb as to when to use padding?

A

When we want to change the appearance of an element

29
Q

When should we padding instead of margin?

A
  1. When we don’t want content touching the sides
  2. You need space between a parent and child element
  3. You want to increase the size of an element but not the content.
30
Q

How might we use background-position on a background image?

A

We might use background-position to lock where an image resizes from:

top left, center right, bottom center

31
Q

What does background-repeat: round; do for us?

A

It rounds up or down a repeating background image so that it does not get cut at container edges but will expand the image

32
Q

What property and value can we use to prevent a background image from being sliced at container edges?

A

background-repeat: round;

or

background-repeat: space;

33
Q

What is the difference between background-repeat: space and background-repeat: round?

A

space distributes the image evenly

round scales the images to fit