Flexbox Flashcards

1
Q

What is the aim of the flexbox layout?

A

To provide a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic (thus the word “flex”).

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

Is the flexbox layout direction agnostic?

A

Yes, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based).

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

What is the most appropriate layout for the components of an application and small-scale layouts, Flexbox or Grid?

A

Flexbox layout is most appropriate to the components of an application, and small-scale layouts, while the Grid layout is intended for larger scale layouts.

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

What is a “flex container”?

A

A parent element with flex properties.

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

What is a “flex item”?

A

A child element with flex properites

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

If “regular” layout is based on both block and inline flow directions, the flex layout is based on ___?

A

flex-flow directions

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

How do you define a flex container?

A
.container {
    display: flex; /* or inline-flex */
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What path will flexbox items follow in a layout?

A

Items will be laid out following either the main axis (from main-start to main-end) or the cross axis (from cross-start to cross-end).

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

What is the main axis of a flex container?

A

The main axis of a flex container is the primary axis along which flex items are laid out.

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

Does the main axis follow a horizontal path?

A

It is not necessarily horizontal; it depends on the flex-direction property.

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

What is the cross axis?

A

The axis perpendicular to the main axis is called the cross axis. Its direction depends on the main axis direction.

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

Is display a property for the parent or the child?

A

Parent – This defines a flex container; inline or block depending on the given value. It enables a flex context for all its direct children.

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

Is order a property for the parent or the child?

A

Child – By default, flex items are laid out in the source order. However, the order property controls the order in which they appear in the flex container.

.item {
    order: 5; /* default is 0 */
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Is flex-direction a property for the parent or the child?

A

Parent – This establishes the main-axis, thus defining the direction flex items are placed in the flex container.

.container {
    flex-direction: row | row-reverse | column | column-reverse;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Flexbox is (aside from optional wrapping) a _______-direction layout concept.

A

Single. Think of flex items as primarily laying out either in horizontal rows or vertical columns.

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

Is flex-grow a property for the parent or the child?

A

Child – This defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion.

.item {
    flex-grow: 4; /* default 0 */ 
}
17
Q

If all items have flex-grow set to __, the remaining space in the container will be distributed equally to all children.

A

Set to 1.

18
Q

Is flex-wrap a property for the parent or the child?

A

Parent – By default, flex items will all try to fit onto one line. You can change that and allow the items to wrap as needed with this property.

.container {
    flex-wrap: nowrap | wrap | wrap-reverse;
}
19
Q

Is flex-shrink a property for the parent or the child?

A

Child – This defines the ability for a flex item to shrink if necessary.

.item {
    flex-shrink: 3; /* default 1 */
}
20
Q

Is flex-flow a property for the parent or the child?

A

Parent – This is a shorthand for the flex-direction and flex-wrap properties, which together define the flex container’s main and cross axes. The default value is row nowrap.

.container {
    flex-flow: flex-direction; /* or flex-wrap */
}
21
Q

Is flex-basis a property for the parent or the child?

A

Child – This defines the default size of an element before the remaining space is distributed. It can be a length (e.g. 20%, 5rem, etc.) or a keyword. The auto keyword means “look at my width or height property”.

.item {
    flex-basis: | auto; /* default auto */
}
22
Q

Is justify-content a property for the parent or the child?

A

Parent – This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size.

.container {
    justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;
}
23
Q

Is flex a property for the parent or the child?

A

Child – This is the shorthand for flex-grow, flex-shrink and flex-basis combined. The second and third parameters (flex-shrink and flex-basis) are optional. The default is 0 1 auto, but if you set it with a single number value, it’s like 1 0.

.item {
    flex: none | [? ||]
}
24
Q

Is align-self a property for the parent or the child?

A

Child – This allows the default alignment (or the one specified by align-items) to be overridden for individual flex items.

.item {
    align-self: auto | flex-start | flex-end | center | baseline | stretch;
}
25
Q

Is align-items a property for the parent or the child?

A

Parent – This defines the default behavior for how flex items are laid out along the cross axis on the current line. Think of it as the justify-content version for the cross-axis (perpendicular to the main-axis).

.container {
    align-items: stretch | flex-start | flex-end | center | baseline | first baseline | last baseline | start | end | self-start | self-end + ... safe | unsafe;
}
26
Q

Is align-content a property for the parent or the child?

A

Parent – This aligns a flex container’s lines within when there is extra space in the cross-axis, similar to how justify-content aligns individual items within the main-axis.

.container {
    align-content: flex-start | flex-end | center | space-between | space-around | space-evenly | stretch | start | end | baseline | first baseline | last baseline + ... safe | unsafe;
}
27
Q

Will the align-content property have an effect on a single row?

A

No, this property has no effect when there is only one line of flex items.