#layoutpatterns

Layout Design Patterns

John Ferris

aten.io

We have problems.

We Solving Problems

Design Patterns

Common solutions
to reoccurring problems
within a given context

Reoccurring Problem

I get Hangry

Common Solution

TACOS!

https://flic.kr/p/9pnN8n

https://flic.kr/p/9pnN8n

Given Context

You like tacos.

You can make or buy tacos.

Layout

CSS Layout

Box Model Properties

  • box-sizing
  • height
  • width
  • max-height
  • max-width
  • border-width
  • padding
  • margin

CSS Layout

Flow Properties

  • display
  • float
  • clear
  • overflow
  • flex-*
  • shape-*

CSS Layout

Position Properties

  • position
  • top
  • right
  • bottom
  • left
  • transform
  • z-index

Patterns

Constrained Elements

Give an element a defined width to prevent it from expanding too wide.

The essence of this process is very fundamental indeed. We may understand it best by comparing the work of a fifty-year-old carpenter with the work of a novice. The experienced carpenter keeps going. He doesn't have to keep stopping, because every action he performs, is calculated in such a way that some later action can put it right to the extent that it is imperfect now. What is critical here, is the sequence of events. The carpenter never takes a step which he cannot correct later; so he can keep working, confidently, steadily.

The novice by comparison, spends a great deal of his time trying to figure out what to do. He does this essentially because he knows that an action he takes now may cause unretractable problems a little further down the line; and if he is not careful, he will find himself with a joint that requires the shortening of some crucial member – at a stage when it is too late to shorten that member. The fear of these kinds of mistakes forces him to spend hours trying to figure ahead: and it forces him to work as far as possible to exact drawings because they will guarantee that he avoids these kinds of mistakes.

.l--constrained

Rows of Relevant Content

Divide the screen into rows of relevant content such that the hierarchy and content relationships are preserved across different screen sizes.

Layout Modifiers

Follow a naming convention for classes intended to modify layout.

Reusable Layouts

            
  
...
...
...
            
  .l--3-column {
    > .l-primary   { @include span(4 at 1); }
    > .l-secondary { @include span(4 at 5); }
    > .l-tertiary  { @include span(4 at 9); }
  }
            
          
            
  .l--sidebars-after {
    > .l-primary   { @include span(6 at 1); }
    > .l-secondary { @include span(3 at 7); }
    > .l-tertiary  { @include span(3 at 10); }
  }
            
          
            
  .l--sidebars-before {
    > .l-primary   { @include span(6 at 7); }
    > .l-secondary { @include span(3 at 1); }
    > .l-tertiary  { @include span(3 at 4); }
  }
            
          
            
  .l--triptych {
    > .l-primary   { @include span(6 at 4); }
    > .l-secondary { @include span(3 at 1); }
    > .l-tertiary  { @include span(3 at 10); }
  }
            
          

Component Layouts

            
  
            
          
            
  .article--teaser {
    > .article-figure  { ... }
    > .article-header  { ... }
    > .article-content { ... }
  }
            
          

Gutter Pull

Position an item by pulling
it into the gutter established
by its parent container.

The essence of this process is very fundamental indeed. We may understand it best by comparing the work of a fifty-year-old carpenter with the work of a novice. The experienced carpenter keeps going. He doesn't have to keep stopping, because every action he performs, is calculated in such a way that some later action can put it right to the extent that it is imperfect now. What is critical here, is the sequence of events. The carpenter never takes a step which he cannot correct later; so he can keep working, confidently, steadily.

Drawings help people to work out intricate relationships between parts.
Christopher Alexander

The novice by comparison, spends a great deal of his time trying to figure out what to do. He does this essentially because he knows that an action he takes now may cause unretractable problems a little further down the line; and if he is not careful, he will find himself with a joint that requires the shortening of some crucial member – at a stage when it is too late to shorten that member. The fear of these kinds of mistakes forces him to spend hours trying to figure ahead: and it forces him to work as far as possible to exact drawings because they will guarantee that he avoids these kinds of mistakes.

A Pattern Language

by Christopher Alexander, Sara Ishikawa, Murray Silverstein and Max Jacobson (1977)

At the core of these books is the idea that people should design for themselves their own houses, streets, and communities. This idea may be radical (it implies a radical transformation of the architectural profession) but it comes simply from the observation that most of the wonderful places of the world were not made by architects but by the people.

            
  
...

...

...

...

            
  .book--teaser {
    padding-left: 10em;
  }
            
          
            
  .book--teaser {
    padding-left: 10em;
  }
  .book--teaser > .book-cover {
    width: 8em;
    float: left;
  }
            
          
            
  .book--teaser {
    padding-left: 10em;
  }
  .book--teaser > .book-cover {
    float: left;
    width: 8em;
    margin-left: -10em;
  }
            
          
            
  .book--teaser {
    max-width: 32em;
    padding-left: 10em;
  }
  .book--teaser > .book-cover {
    float: left;
    width: 8em;
    margin-left: -10em;
  }
            
          

Margin Overflow

Allow an element to overflow its container by applying negative margins to both left and rights sides.

Layout Design Patterns

Layout Design patterns are recurring solutions that solve common layout design problems.

            
  

...

...
            
  .block-title {
    margin-right: -4em;
    margin-left: -4em;
  }
            
          
Everyone is aware that most of the built environment today lacks a natural order, an order which presents itself very strongly in places that were built centuries ago.
In short, no pattern is an isolated entity. Each pattern can exist in the world only to the extent that is supported by other patterns: the larger patterns in which it is embedded, the patterns of the same size that surround it, and the smaller patterns which are embedded in it.
The more living patterns there are in a place - a room, a building, or a town - the more it comes to life as an entirety, the more it glows, the more it has that self-maintaining fire which is the quality without a name.
            
  
            
  .l--3-columns > .l-column {
    box-sizing: border-box;
    float: left;
    width: 33.333%;
    padding: 0 2em;
  }
            
          
            
  .l--3-columns {
    margin-right: -2em;
    margin-left: -2em;
  }

  .l--3-columns > .l-column {
    box-sizing: border-box;
    float: left;
    width: 33.333%;
    padding: 0 2em;
  }
            
          

Intrinsic Ratios

When the aspect ratio of an element is known, but the target size is not, use padding and absolute positioning to preserve the aspect ratio of an element.

  
  
            
  .video {
    position: relative;
    padding-top: 62.25%;  // Video height / width.
    height: 0;
  }
            
          
            
  .video {
    position: relative;
    padding-top: 62.25%;  // Video height / width.
    height: 0;
  }

  .video-inner {
    position: absolute;
    top: 0;
    height: 100%;
    width: 100%;
  }
            
          
Villard Diagram
c. 1458
Josef Muller's Grid Systems
Marber's Penguin Grid
Marber's Penguin Grid
Olly Moss - Video Game Covers
Olly Moss - Dark Knight
Olly Moss - Dark Knight
Olly Moss - Dark Knight

Guttered Grid

For each grid unit in the grid system, include a gutter to help space content.

960 grid system

Gutter-less Grid

Exclude gutters from the grid unit. Instead, use empty columns as gutters.

Symmetric Grid

Construct the grid from equal width grid units.

960 grid system

Asymmetric Grid

Construct the grid from varied width grid units designed for content.

Class-based Grid System

Align elements to the grid
by applying a system of
predefined classes to markup.

Foundation grid system
            
  
  
...
...
...

Semantic Grid System

Align elements to the grid
by applying layout properties
to selectors using a grid framework.

            // Singularity - http://singularity.gs/
.l--sidebar-after {
  > .l-primary   { @include grid-span(8, 1, 12); }
  > .l-secondary { @include grid-span(4, 9, 12); }
}
          
// Susy - http://susy.oddbird.net/
.l--sidebar-after {
  > .l-primary   { @include span(8 at 1 of 12); }
  > .l-secondary { @include span(4 at 9 of 12); }
}
          
// Zen Grids - http://zengrids.com/
.l--sidebar-after {
  > .l-primary   { @include zen-grid-item(8, 1, $column-count: 12); }
  > .l-secondary { @include zen-grid-item(4, 9, $column-count: 12); }
}
          

Flow Layout

Create columns by inlining a series of elements with defined widths, allowing elements to wrap as needed.

            
              
...
...
...
            
  .l--3-columns > .l-column {
    width: 33.333%;
  }
            
          
            
  .l--3-columns > .l-column {
    width: 33.333%;
    float: left;
  }
            
          
            
  .l--3-columns > .l-column {
    width: 33.333%;
    float: left;
    box-sizing: border-box;
    padding: 0 2em;
  }
            
          
            
  .l--3-columns > .l-column {
    width: 50%;
    float: left;
    box-sizing: border-box;
    padding: 0 2em;
  }
            
          
Flow Layout

Isolation Layout

Given a series of floated elements, give each a negative trailing margin in order to reset the orientation of the following element.

            
  .l--isolation {
    > .l-primary {
      width: 33.333%;
    }
    > .l-secondary {
      width: 33.333%;
    }
    > .l-tertiary {
      width: 33.333%;
    }
  }
            
          
            
  .l--isolation {
    > .l-primary {
      width: 33.333%;
      margin-right: -33.333%;
    }
    > .l-secondary {
      width: 33.333%;
      margin-right: -33.333%;
    }
    > .l-tertiary {
      width: 33.333%;
    }
  }
}
            
          
            
  .l--isolation {
    > .l-primary {
      width: 33.333%;
      margin: 0 -100% 0 66.666%;  // margin-right: -1 * (margin-left + width)
    }
    > .l-secondary {
      width: 25%;
      margin: 0 -50% 0 25%;  // margin-right: -1 * (margin-left + width)
    }
    > .l-tertiary {
      width: 33.333%;
    }
  }
}
            
          
            
  .l--isolation {
    > .l-primary {
      width: 42%;
      margin: 0 -100% 0 58%;  // margin-right: -1 * (margin-left + width)
    }
    > .l-secondary {
      width: 33.333%;
      margin-right: -33.333%;
    }
    > .l-tertiary {
      width: 33.333%;
    }
  }
}
            
          
            
  .l--isolation {
    > .l-primary   { float: left; }
    > .l-secondary { float: right; }

    > .l-tertiary {
      clear: left;
      float: left;
    }
  }
}
            
          
Flow vs Isolate Layout
Flow vs Isolate Layout

Patterns in the wild

uipatterns.com
Multi-device Layout Patterns
Responsive Layout Patterns

Christopher Alexander

1936 -

Christopher Alexander

https://flic.kr/p/ngz4YL

Design Patterns are not designed.

Design Patterns are observed.

Start looking for patterns

Be mindful of feel good code.

Make it Repeatable.

Share it with others.

Thank you.


Text: (504) 229-6828

#layoutpatterns [1-5] [Comment]