Skip to main content
This page provides a comprehensive reference of CSS properties used throughout the ML Store project, organized by category.

Layout Properties

Display

PropertyValuesPurposeExample from Project
displayblock, inline, inline-block, flex, grid, noneElement display type.header__container { display: flex; }
flex-directionrow, column, row-reverse, column-reverseFlex layout directionDefault is row
justify-contentflex-start, flex-end, center, space-between, space-around, space-evenlyMain axis alignment.header__container { justify-content: space-between; }
align-itemsflex-start, flex-end, center, stretch, baselineCross axis alignment.header__container { align-items: center; }
flex<grow> <shrink> <basis>Flex item sizing.header__search { flex: 1; }
gap<length>Space between flex/grid itemsgap: var(--spacing-md);

Grid Layout

.benefits__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-lg);
}
PropertyPurposeExample
grid-template-columnsDefine column tracksrepeat(3, 1fr)
grid-template-rowsDefine row tracksauto 1fr auto
grid-columnItem column position1 / -1 (span all)
grid-rowItem row position2 / 4
gapSpace between grid itemsgap: 1rem 2rem

Positioning

PropertyValuesPurpose
positionstatic, relative, absolute, fixed, stickyPositioning method
top, right, bottom, left<length>, <percentage>Position offset
z-index<integer>Stacking order
/* Sticky header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Absolute cart badge */
.header__nav-link--cart::after {
  position: absolute;
  top: -4px;
  right: -8px;
}

Box Model

Spacing

PropertyPurposeShorthand
marginOuter spacingmargin: top right bottom left
paddingInner spacingpadding: top right bottom left
widthElement widthwidth: 100%
heightElement heightheight: auto
max-widthMaximum widthmax-width: 1200px
min-heightMinimum heightmin-height: 100vh
Shorthand patterns:
  • margin: 10px - All sides
  • margin: 10px 20px - Vertical | Horizontal
  • margin: 10px 20px 30px - Top | Horizontal | Bottom
  • margin: 10px 20px 30px 40px - Top | Right | Bottom | Left (clockwise)

Border

.product-card {
  border: 1px solid var(--color-gray-200);
  border-radius: var(--border-radius-md);
}
PropertyValuesExample
border<width> <style> <color>1px solid #ccc
border-width<length>2px
border-stylesolid, dashed, dotted, nonesolid
border-color<color>#333
border-radius<length>, <percentage>8px, 50%

Box Sizing

*, *::before, *::after {
  box-sizing: border-box;
}
ValueBehavior
content-boxWidth = content only
border-boxWidth = content + padding + border

Typography

Font Properties

PropertyPurposeExample
font-familyFont stackvar(--font-family-base)
font-sizeText sizevar(--font-size-lg)
font-weightText weight400, 600, 700, bold
line-heightLine spacing1.5
letter-spacingCharacter spacing0.5px
text-alignHorizontal alignmentleft, center, right
text-transformCase transformationuppercase, lowercase, capitalize
text-decorationText decorationnone, underline
.product-card__category {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-gray-500);
}

Text Overflow

.product-card__title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Colors and Backgrounds

Color Properties

PropertyPurposeExample
colorText colorcolor: var(--color-gray-600)
background-colorBackground colorbackground-color: var(--color-white)
backgroundBackground shorthandbackground: linear-gradient(...)
opacityTransparencyopacity: 0.6

Gradients

.hero {
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-dark) 50%,
    #FFD700 100%
  );
}
Use linear-gradient() for linear gradients and radial-gradient() for radial patterns.

Visual Effects

Shadows

.product-card {
  box-shadow: var(--shadow-sm);
}

.product-card:hover {
  box-shadow: var(--shadow-lg);
}
PropertySyntaxExample
box-shadowoffset-x offset-y blur spread color0 4px 6px rgba(0,0,0,0.1)
text-shadowoffset-x offset-y blur color1px 1px 2px rgba(0,0,0,0.3)

Overflow

PropertyValuesPurpose
overflowvisible, hidden, scroll, autoContent overflow behavior
overflow-xSame as aboveHorizontal overflow
overflow-ySame as aboveVertical overflow

Transitions and Animations

Transitions

.header__logo-link {
  transition: transform var(--transition-fast);
}

.header__logo-link:hover {
  transform: scale(1.02);
}
PropertyValuesPurpose
transitionproperty duration timing-function delayShorthand
transition-propertyall, transform, opacity, etc.What to animate
transition-duration<time>How long (e.g., 300ms)
transition-timing-functionease, linear, ease-in, ease-outAnimation curve
transition-delay<time>Delay before start

Transforms

.product-card:hover {
  transform: translateY(-8px);
}

.product-card:hover .product-card__image {
  transform: scale(1.05);
}
FunctionPurposeExample
translate(x, y)Move elementtranslateY(-10px)
scale(x, y)Resize elementscale(1.1)
rotate(angle)Rotate elementrotate(45deg)
skew(x, y)Skew elementskewX(10deg)

Keyframe Animations

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.products__spinner {
  animation: spin 1s linear infinite;
}
PropertyValuesPurpose
animationname duration timing-function iteration-countShorthand
animation-name<keyframe-name>Which @keyframes to use
animation-duration<time>Duration of animation
animation-iteration-count<number>, infiniteHow many times
animation-timing-functionease, linear, etc.Animation curve

CSS Variables (Custom Properties)

Defining Variables

:root {
  --color-primary: #FFE600;
  --spacing-md: 1rem;
  --border-radius-sm: 4px;
}

Using Variables

.button {
  background-color: var(--color-primary);
  padding: var(--spacing-md);
  border-radius: var(--border-radius-sm);
}

Responsive Design

Media Queries

/* Mobile first approach */
.container {
  padding: 1rem;
}

/* Tablet and up */
@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .container {
    padding: 3rem;
  }
}

Viewport Units

UnitMeaningExample
vw1% of viewport widthwidth: 50vw
vh1% of viewport heightmin-height: 100vh
vmin1% of smaller dimensionfont-size: 5vmin
vmax1% of larger dimensionwidth: 80vmax

Pseudo-Classes

SelectorTriggers WhenExample
:hoverMouse over element.button:hover { }
:focusElement has focusinput:focus { }
:activeElement being clicked.button:active { }
:first-childFirst child of parentli:first-child { }
:last-childLast child of parentli:last-child { }
:nth-child(n)Nth childtr:nth-child(odd) { }
:not(selector)Not matching selector.item:not(.active) { }

Pseudo-Elements

.header__nav-link--cart::after {
  content: attr(data-cart-count);
  position: absolute;
  /* ... */
}
SelectorPurposeExample
::beforeInsert before content.icon::before { content: "→"; }
::afterInsert after content.badge::after { content: "New"; }
::first-letterFirst letter stylingp::first-letter { font-size: 2em; }
::first-lineFirst line stylingp::first-line { font-weight: bold; }
::placeholderInput placeholderinput::placeholder { color: #999; }

Advanced Selectors

SelectorMeaningExample
.a .bDescendant.header .logo (any level)
.a > .bDirect child.list > .item
.a + .bAdjacent siblingh2 + p (immediately after)
.a ~ .bGeneral siblingh2 ~ p (any after)
[attribute]Has attribute[data-active]
[attr="value"]Exact match[type="text"]
[attr^="value"]Starts with[href^="https"]
[attr$="value"]Ends with[src$=".png"]
[attr*="value"]Contains[class*="btn"]

Common Patterns from Project

Centering Container

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

Flexbox Centering

.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

Responsive Grid

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

Smooth Transition

.element {
  transition: all 0.3s ease;
}
.element:hover {
  transform: scale(1.05);
}

Next Steps

CSS Fundamentals

Learn CSS concepts in depth

TypeScript Types

TypeScript reference guide

Common Patterns

Code patterns and best practices

Build docs developers (and LLMs) love