Positioning Flashcards

(20 cards)

1
Q

What are the five values for the CSS position property?

A

static, relative, absolute, fixed, and sticky.

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

What is position: static?

A

The default. The element follows normal document flow. top, right, bottom, left, and z-index have no effect.

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

What does position: relative do?

A

The element stays in normal flow but can be offset from its original position using top/right/bottom/left. The space it originally occupied is preserved.

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

Does position: relative affect other elements?

A

No — the element is offset visually, but other content is not adjusted to fill the gap left behind.

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

What does position: absolute do?

A

The element is removed from normal flow and positioned relative to its nearest positioned ancestor (or the initial containing block if none exists).

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

What is a ‘positioned’ element?

A

Any element whose computed position is relative, absolute, fixed, or sticky — anything except static.

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

What is the containing block for an absolutely positioned element?

A

The nearest ancestor with a position other than static. If there is none, it’s the initial containing block (the viewport).

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

What does position: fixed do?

A

The element is removed from normal flow and positioned relative to the viewport. It stays in place even when the page scrolls.

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

How does fixed differ from absolute?

A

Fixed positioning always uses the viewport as its reference, while absolute uses the nearest positioned ancestor.

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

What does position: sticky do?

A

The element acts as relatively positioned until it crosses a scroll threshold (e.g. top: 10px), then it becomes fixed within its scrolling container.

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

What determines when a sticky element ‘sticks’?

A

The offset values (top, right, bottom, left) define the threshold at which the element transitions from relative to fixed behavior.

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

What is the z-index property?

A

It controls the stacking order of positioned elements. Higher values appear in front of lower values. Only works on positioned elements (not static).

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

Can you use z-index on a statically positioned element?

A

No — z-index only applies to positioned elements. A positioned element will always stack above a static one by default.

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

What is a stacking context?

A

A three-dimensional conceptualization of HTML elements along a z-axis. Created by elements with certain properties like position + z-index, opacity < 1, or transform.

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

What happens to child elements when a parent has position: relative?

A

The parent becomes the containing block for any absolutely positioned descendants inside it.

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

What offset properties are used with positioned elements?

A

top, right, bottom, and left — they specify the distance from the respective edge of the containing block.

17
Q

Does a sticky element remain fixed forever?

A

No — it only stays fixed while its parent container is visible in the viewport. Once the parent scrolls out of view, the sticky element scrolls away with it.

18
Q

Can fixed elements cause accessibility issues?

A

Yes — they can overlap content, making it inaccessible. Ensure enough space is available and test at different viewport sizes.

19
Q

What performance concern exists with sticky/fixed positioning?

A

The browser must repaint these elements in their new position on every scroll. Using will-change: transform can help by promoting the element to its own compositing layer.

20
Q

When should you set an element to position: static explicitly?

A

Only to remove positioning applied by another rule — since static is the default, you rarely need to set it yourself.