Web Development

Dr Derek Bridge
School of Computer Science & Information Technology
University College Cork

Lecture Objectives

  • learn about page layout and component layout
  • learn a little about flexbox
  • learn a little about grid layout

Warning

Fog of details ahead!

Do not 'learn off'.
Look-up when needed.

Page Layout

  • Recall: fixed-width and liquid layouts
  • Multicolumn page layout, with two or three columns, is very common!
    A three-column layout comprising a header across the top, then a nav, a main and an aside side-by-side, and a footer across the bottom.

Layout

CSS Layouts

Flow layout:
Based on the outer display type of each element.
Flexbox:
One-dimensional layout based on rows or columns but elements can 'flex' to fill additional space or shrink to fit smaller spaces.
Grid layout:
Two-dimensional layout.

Other: floating, positioning, multicolumn text.

Example

Responsive Web Design (RWD)

In RWD, we adapt the layout to the characteristics of the device/window.

E.g. page layout
one-column layout for narrow devices/windows;
two-column layout when there is more room;
three-column layout when there is even more room.

E.g. component layout
elements are stacked on narrow devices/windows;
they are side-by-side when there is more room.

CSS Flexbox

A flexbox contains items, which are laid out in a one-dimensional way,
either in rows or in columns.

The items in the flexbox can 'flex',
grow or shrink.

Don't use flexbox when flow layout is sufficient!

Flexbox Properties

A Complete Guide to Flexbox

On the container:
display: flex;

Parent properties
(the flexbox itself)
(the container)
Child properties
(the flex items)
(the contents)
flex-direction order
flex-wrap flex-grow
justify-content flex-shrink
align-items flex-basis
align-content align-self

Example

We see a big blue area with three yellow boxes, layed out using flow layout.

Example, cont'd

Example, cont'd

CSS Grid Layout

Grid Layout makes two-dimensional layouts easy (easier).

A grid contains items arranged in columns and rows

A Complete Guide to Grid Layout

CSS Grid Layout

A grid contains items arranged in columns and rows

Example, cont'd

G'luck!