Teaching Presentation: Fluid Layouts

Creating Designs That Respond to Different Devices

Using Proportions, Not Pixels

This is an educational project.

Converting Pixels to Proportions

There is a mathematical formula to convert pixel based layouts to proportions.
target ÷ context = result
(This is just the formula for a percentage.)

Target
is the width of the element in pixels.
Context
is the width of the layout in pixels.
Result
is the percentage that the element needs to be in CSS.

Example: 25 px margin ÷ 960 px page width 25 px margin = .026 (or 2.6%)
The margin value in CSS would be listed as 2.6%
(Ben Frain)

Using Ems Instead of Pixels

Ems are based on the size of the text font. In 16 point font, it is 16 points wide.
Modern browsers use 16 px as the default size.
Therefore, these values in CSS would produce identical font sizes.

font-size: 100%;
font-size: 16px;
font-size: 1 em;

By changing the font-size to 1.5 em, the text would display at 150%, or 24px.
Note: The em can also be based on a font size you specify.
(Ben Frain)

Grid Layouts Instead of Tables

Unlike Tables, Grid Layouts create a structure that's flexible to fit different sized screens.

A Grid:

For examples of grid layouts, view the whole W3C CSS3 Grid Layout article at: http://www.w3.org/TR/2013/WD-css3-grid-layout-20130402/

Fluid Layout in CSS

Resources