CSS rules, selectors, box model, Flexbox, Grid

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

21 Terms

1
New cards

CSS Rules

Rules: selector { property: value; }.

CSS properties control:

Typography - color, font family, size, weight, and style.

Spacing- margin, padding, and gaps.

Layout - display, position, flexbox, and grid.

Surfaces - backgrounds, borders, radius, and shadows.
Interaction - transitions, transforms, and animations.

2
New cards

Classes

Classes are reusable (.card)

A reusable grouping attribute.

Many elements (even different element type) can share a class.

An element can have multiple classes.

3
New cards

ID

IDs are unique (#card)

A unique identifier for one element.

Each ID value must be unique within the document.

An element can have one ID.

4
New cards

Type selectors

type selectors target tags (p)

5
New cards

CSS Selectors

A B means descendant
A > B direct child
A + B the immediately following sibling
A, B groups matches (Matches both all a elements and all b elements independently)

6
New cards

CSS Specificity Hierarchy

Inline styles > IDs (#id) > Classes / Attributes / Pseudo-classes (.class, [attr], :hover) > Types / Pseudo-elements (div, ::before)

A directly specified child property overrides inherited parent styling.

7
New cards

Block and Inline

Block boxes start on a new line and expand across available width whereas inline boxes flow within a line and are only as wide as their content.

8
New cards

Box model (inside → outside)

content, padding, border, margin

Margins and padding are transparent

9
New cards

content-box vs. border-box

  • content-box (width behavior): The width property applies strictly to the inner content area, causing padding and borders to add onto the outside and increase the rendered box size.

  • border-box (width behavior): The width property includes content, padding, and borders inside that exact measurement, shrinking the inner content area to make room.

  • Rendered Outer Width: Under content-box, rendered width equals width + L/R padding + L/R border, whereas under border-box, rendered width equals the specified width.

  • Margins in Both Models: Margins always sit outside the rendered border edge and add to total occupied horizontal space in both content-box and border-box.


10
New cards

Flex Container

Flex container is the element with display:flex

only its direct children become flex items.

11
New cards

Flex-direction

flex-direction sets the main axis

Row is the default, row reverse reverse their order along that axis.

Column stacks items vertically. column reverse reverse the vertical order.

justify-content distributes free space along main axis

align-items works on the cross axis;

flex-wrap allows new lines for flex objects;

order changes visual order but not DOM/keyboard order

12
New cards

Grid

Flexbox follows one main axis whereas Grid establishes a two-dimensional coordinate system.

13
New cards

Grid container

The parent with display:grid or display:inline-grid

14
New cards

Grid items

The children of the Grid container

15
New cards

Container properties

Define tracks, gaps, flow, and default alignment

16
New cards

Flexible Shares

(fr): grid-template-columns: 1fr 2fr; splits available space into proportional shares (1 part and 2 parts).

17
New cards

Track Spacing

(gap): gap sets uniform spacing directly between grid rows and columns without needing margins.

18
New cards

Spanning Tracks

grid-column: 1 / 3; makes an item stretch from grid line 1 to grid line 3 (spanning two columns).

19
New cards

Media Queries

(@media): Media queries conditionally apply CSS rules when the viewport reaches specific widths or breakpoints.

20
New cards

Fluid Sizing & Images

Using percentage-based fluid widths alongside max-width: 100%; on images prevents content from overflowing smaller screens.

21
New cards

Viewport Meta Tag

Mobile pages require <meta name="viewport" content="width=device-width, initial-scale=1"> in the <head> so mobile browsers match the CSS viewport to the actual screen width.