Week 5 Flashcards

Covers all content taught in week 5 (41 cards)

1
Q

What is the primary original use of the float property in CSS?

A

Wrapping text around images or similar inline elements.

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

What happens when an element is floated?

A

It is removed from the normal document flow.

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

How can you prevent content from wrapping around a floated element?

A

Use clear: left, right, or both.

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

Is float recommended for layout today?

A

No, it’s outdated for layout; use Flexbox or Grid instead.

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

What type of layout is Flexbox best suited for?

A

One-dimensional layouts (row OR column).

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

How do you enable Flexbox on a container?

A

display: flex

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

What property controls the direction of Flexbox items?

A

flex-direction

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

What does justify-content control?

A

Main axis alignment (left, center, space-between, etc.)

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

What does align-items control?

A

Cross axis alignment (top, center, stretch, etc.)

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

What type of layout is CSS Grid best suited for?

A

Two-dimensional layouts (rows and columns).

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

How do you enable CSS Grid?

A

display: grid

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

How do you define column sizes in a grid?

A

With grid-template-columns, e.g. 1fr 2fr

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

How do you place a grid item in a specific cell?

A

Use grid-row and grid-column.

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

What is a fixed layout?

A

A layout with a set pixel width that doesn’t adapt to screen size.

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

What is a fluid layout?

A

A layout that uses percentages and stretches/shrinks with screen size

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

What is an elastic layout?

A

A layout that uses relative units like em or rem and scales with font size.

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

What is a responsive layout?

A

A layout that adapts to any screen using relative units and media queries.

18
Q

What is an adaptive layout?

A

A layout that switches between predefined fixed layouts at breakpoints.

19
Q

What is the purpose of responsive design?

A

To ensure websites work well on all screen sizes.

20
Q

What meta tag is essential for responsive design?

A

<meta></meta>

21
Q

How do you write a media query for max width 768px?

A

@media (max-width: 768px) { … }

22
Q

What are common screen size breakpoints for media queries?

A

Mobile: ≤ 480px

Tablet: 481–768px

Desktop: 769–1200px+

23
Q

How do you neatly space elements in a footer using Flexbox?

A

Use display: flex on the footer container with justify-content: space-between to spread items evenly—perfect for placing contact info on one side and links/copyright on the other.

24
Q

How can you create a responsive navigation bar with Flexbox?

A

Use flex-direction: row for desktops and switch to column with media queries for mobile devices. This stacks menu items vertically on smaller screens.

25
How does Flexbox ensure consistent product card layouts?
Combine flex-direction: column, justify-content: space-between, flex-wrap, and flex-grow to evenly distribute content (image, text, button) while keeping the button at the bottom, regardless of text length.
26
How do you design a responsive testimonial section?
Use flex-wrap for responsiveness, align-items: center for balanced text/image alignment, and border-radius for circular images to create a polished, professional look.
27
How can Flexbox center a custom shape like a diamond?
Apply justify-content and align-items: center to center the shape both vertically and horizontally, and use clip-path to create the diamond effect.
28
What’s the key takeaway from these Flexbox examples?
Flexbox gives you powerful control over alignment, spacing, and responsiveness—perfect for everything from structural layout to creative designs.
29
What is CSS Grid and how is it different from Flexbox?
CSS Grid is a two-dimensional layout system that uses rows and columns, while Flexbox handles only one dimension (row or column). Grid offers full control for complex page structures.
30
How do you turn a container into a grid?
.grid-container { display: grid; grid-template-columns: auto auto auto; grid-template-rows: auto; gap: 10px; }
31
How do you position an item using CSS Grid?
.grid-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1; }
32
Why is CSS Grid useful for responsive layouts?
It allows dynamic resizing of rows and columns using units like fr, auto, and media queries—making layouts clean, scalable, and better maintained than float/position methods.
33
How do you create a simple gallery layout using Grid?
.grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
34
How can you build a news website layout using CSS Grid?
Columns: Main content (3fr) and sidebar (1fr) Rows: Header, content, footer Header/Footer span both columns using grid-column: 1 / -1 Keeps content organized while resizing smoothly.
35
How does a responsive card layout work using Grid?
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; } @media (max-width: 600px) { .grid-container { grid-template-columns: 1fr; } }
36
What key properties does CSS Grid use for item alignment?
justify-items / align-items: Align items within their grid cells justify-content / align-content: Control the whole grid’s position inside its container place-items / place-content: Shorthand for combining horizontal and vertical alignment
37
What is the purpose of grid-template-areas?
It defines named layout areas for clearer and more manageable grid designs.
38
Why use box-sizing: border-box and overflow: hidden with floating grids?
box-sizing: border-box prevents width overflow by including padding and borders in the width calculations. overflow: hidden clears floats, ensuring the parent container wraps around child elements properly.
39
What’s the benefit of manually placing items using grid-column and grid-row?
Precise control over item placement without relying on margins or floats—streamlining complex layouts.
40
What are some advanced CSS Grid container utilities?
gap, row-gap, column-gap: Control spacing grid-auto-flow: Controls how grid items are automatically positioned grid-auto-columns / grid-auto-rows: Define default sizes for implicit tracks
41
What are the key takeaways from both Flexbox and CSS Grid?
Flexbox is ideal for alignment and 1D layouts with creative and practical uses. CSS Grid simplifies complex 2D layouts with explicit control of both rows and columns. Both methods enhance responsiveness and clean code, replacing older float-based techniques.