liveBook · Manning

Slope

As explained in Math for Web Design

Rate of change is the amount by which one variable changes relative to a change in another variable.

Slope measures how much one variable changes relative to another. In a linear equation, it is the constant rate of change: y = mx + b, where m is the slope and b is the starting value when x is 0. In frontend work, slope models changing size, position, speed, and progress. section 1.4.5

y = mx + b

Use the linear-equation form y = mx + b to identify the rate of change, input, output, and starting value. section 1.4.5

A fluid container width

A container grows from 400px at a 500px viewport to 800px at a 1000px viewport. Its slope is (800 - 400) / (1000 - 500) = 0.8, so its unclamped width is 0.8 × the viewport width. CSS can preserve that relationship with width: clamp(400px, 80vw, 800px), keeping the result within the intended bounds. section 6.5.3

Slope supports several practical frontend calculations:

  • Map scroll distance to progress with progress = scrollY / totalHeight. section 1.4.5
  • Represent motion with position = initial + speed × time, where speed is the changing rate. section 1.4.5
  • Read animation speed from a cubic Bézier curve: steep slopes produce faster motion, while shallow slopes produce slower motion. section 11.1.4
Table 1.5 Examples of linear equations

Task

Code

Explanation (y = mx + b)

Define a responsive width in CSS.

width: calc(50vw + 20px);

m is 0.5, x is the viewport width, and b is 20px (a fixed offset).

Calculate consistent motion in JavaScript.

const position = initial + speed * time;

m is the variable speed, x is the variable time, and b is the variable initial (the position when time is 0).

Compare slope-based frontend patterns for responsive widths and consistent JavaScript motion. section 1.4.5

How Math for Web Design covers it

How deep it goes
Explains slope through linear equations, worked responsive-width calculations, CSS functions, and animation timing, without deriving Bézier mathematics.
Examples
Uses scroll progress, responsive container widths, JavaScript position, and Bézier animation speed as concrete examples.
What it assumes
Assumes basic variables and algebraic relationships while introducing linear equations through frontend calculations.
What you can do after
Apply slope to build fluid CSS dimensions, calculate JavaScript progress or motion, and tune animation timing.
How it connects
Connects slope to linear equations, responsive design, CSS functions, JavaScript motion, and cubic Bézier curves.

Also explained in

Compare how 5 books explain slope →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.