flex Flashcards

1
Q

css: To make a flex container that stretches the whole width with items lining up from left to right, type

A

.container {
display: flex;
flex-direction: row;
}

note: To make the items line up from right to left instead of left to right, use flex-direction: row-reverse;
note: these flex items will stretch the full height of the container

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

css: To make a flex container that stretches the whole width with items lining up from top to bottom, type

A

.container {
display: flex;
flex-direction: column;
}

note: To make the items line up from right to left instead of left to right, use flex-direction: column-reverse;
note: these flex items will stretch the full width of the container

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

css: flex containers take up

A

the full width (even when flex-direction: column;), but can shrink to just contain the flex items inside it if you use display: inline-flex; instead of display: flex;

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

css: To allow flex items inside a flex container to wrap instead of overflowing by default, type

A

.container {
flex-wrap: wrap;
}

note: This goes on the container, not items

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

css: To align all the flex items in the center of their container, type

A

justify-content: center;

note:
to justify to the right, type
justify-content: flex-end;

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

css: To make the flex items spread out with even space between them, type

A

justify-content: space-around;

or

justify-content: space-between;

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

css: To vertically center flex items in row mode, type

A

target the container

.container {
align-items: center;
}

Note: this can be used center inline elements when in column mode, but only if you use inline elements without section containers like the ones I normally use.

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

css: To change the alignment on just one of the flex items, type

A

.flex-item-2 {
self-align: center;
}

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

css: To set the max-width of a flex item, type

A

.item {
flex-basis: 10%; // flex-basis: 10px;
}

note: This is useful for when you are creating 1 section that stays the same height and then the last one has to grow to fit the screen using flex-grow: 1; Might also need to set flex-shrink: 0; to prevent the max-width from being able to shrink. flex-basis: 10px and flex-shrink: 0 together are effectively a static width.

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

css: Flexbox containers are always by default

A

flex-direction: row;

even if they are nested in a flexbox thats flex-direction: column;

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

css: To create a flex container with 2 fixed width items and one flexible, type

A

https://stackoverflow.com/questions/23794713/how-can-i-have-two-fixed-width-columns-with-one-flexible-column-in-the-center

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

css: You can think of flex-basis exactly like

A

max-width for flex items

https://www.youtube.com/watch?v=j5RxNRFWMwo&index=6&list=PL4cUxeGkcC9i3FXJSUfmsNOx8E7u6UuhG

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

css: To prevent a flex item from shrinking you, set

A

flex-shrink: 0;

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

css: A flex item can simultaneously be a

A

flex container

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

css: basically to get the mobile layouts I want, I must

A

create flex container that is the full height and width
set containers flex-direction to column
set the header sections flex-basis (max-width) to be a set amount
set the flex-shrink to 0 so it can’t shrink
set the header to be a flexbox container as well (display: flex;)
set the headers flex direction to column
set the headers justify-content to center
this way the text in the header will be vertically aligned

I do similar for bottom and the middle will stretch.

since I want to center align the content of each flex item, all the flex items will also need to be flex boxes.

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

css: Any element can be a

A

flex item

17
Q

css: You can make a flex item grow by

A

setting flex-grow to something, or by setting one of its inner elements to width 100%

18
Q

css: all of the children of a flex container are automatically

A

flex items

19
Q

css: setting all flex items in a container to flex: 1; does not automatically set them to have equal widths because

A

if the items content differs in width it will make its section bigger, because it only distributes the free space which is added to the initial width of your items content.

to get equal widths, set flex-basis: 0; on all the flex items

https://stackoverflow.com/questions/25066214/flexbox-not-giving-equal-width-to-elements

20
Q

learn how to use 60vw and vh in css viewport width

A

its similar to a percenttage

21
Q

to imitate a large screen

A

zoom out a lot

22
Q

to disable cache in chrome

A

go to network and click disable cache.

23
Q

to uncache an image

A

add a query string, since caches use the url to know which item was previously loaded.

24
Q

to see which event listeners get triggered when you click on something

A

console, sources, event listener breakpoints, and then check the event you want to get a breakpoint on

25
Q

map, filter, reduce functions

A

https://stackoverflow.com/questions/49934992/main-difference-between-map-and-reduce

26
Q

footer

A

-body>
-div class=”content”>
content
-/div>
-footer class=”footer”>-/footer>
-/body>

 .content {
 min-height: calc(100vh - 70px);
 }
 .footer {
 margin-top:20px;
 background:#efefef;
 padding:50px;
 }