Skip to main content

CSS

CSS properties, Flexbox, Grid, and selectors

Web Development

Flexbox Container

display: flex

Enable flexbox

flex-direction: row | column

Main axis direction

justify-content: center

Align on main axis

align-items: center

Align on cross axis

flex-wrap: wrap

Allow wrapping

gap: 1rem

Space between items

Flexbox Items

flex: 1

Grow to fill space

flex-grow: 1

Growth factor

flex-shrink: 0

Prevent shrinking

flex-basis: 200px

Initial size

align-self: flex-end

Override alignment

Grid Container

display: grid

Enable grid

grid-template-columns: 1fr 1fr

Define columns

grid-template-rows: auto

Define rows

gap: 1rem

Space between cells

grid-template-columns: repeat(3, 1fr)

Repeat pattern

grid-auto-flow: dense

Fill gaps automatically

Grid Items

grid-column: 1 / 3

Span columns

grid-row: 1 / 2

Span rows

grid-area: header

Named area

place-self: center

Center in cell

Selectors

.class

Class selector

#id

ID selector

div > p

Direct child

div p

Descendant

div + p

Adjacent sibling

div ~ p

General sibling

:hover, :focus, :active

State pseudo-classes

::before, ::after

Pseudo-elements

:nth-child(2n)

Every even child

:not(.class)

Negation

Units

px

Pixels (absolute)

rem

Relative to root font-size

em

Relative to parent font-size

%

Percentage of parent

vw, vh

Viewport width/height

fr

Fraction unit (grid)

Privacy-First Developer Toolkits - 35+ Browser-Based Tools