diff --git a/README.md b/README.md
index ac91a2d..57ba29a 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,6 @@
A simple guide to responsive design.
www.adamkaplan.me/grid
-
####Why bother with responsive?
We want our websites to be useable on all devices by responding to the user’s behavior, screen size and screen orientation.
@@ -12,15 +11,30 @@ We want our websites to be useable on all devices by responding to the user’s
As of 2013, there are thousands of different devices and screen sizes that browse the internet, so it's impossible to design layouts to target them all. Instead, we must take a more fluid approach to design.
+####Mobile First
+
+The term “mobile first” gets thrown around a lot lately. What it really means is to start with mobile styles and layer on styles optimized for larger screens only as needed. In other words, your mobile styles become the default and you no longer have to override them later. It’s much simpler!
+
+####Min-width Media Queries
+Introduce layout-specific rules only when you need them. Use `min-width` to layer complexity on your layout as the viewport widens. It’s easier to have all the media queries nearby, rather than at the end of the stylesheet or in a separate document.
+
##Steps
-####1. Add the Viewport Meta Tag
+####2. Not All Browsers are Created oqual
+Browsers will render your CSS differently. To avoid this, it’s a good idea to use a modern alternative to a reset like [Normalize.css](http://necolas.github.io/normalize.css/), which will render elements more consistently cross-browser. Remember to include it as-is before your stylesheet.
+
+```
+
+
+```
+
+####2. Add the Viewport Meta Tag
Place in the `
` of your HTML. This enables use of media queries for cross-device layouts.
```
```
-####2. Use box-sizing: border-box
+####3. Use box-sizing: border-box
Place at the top of your CSS file. The `*` will target all elements on the page.
```
*, *:before, *:after {
@@ -35,93 +49,92 @@ A container holds all elements and controls the page's maximum width. Using a co
```
.container {
margin: 0 auto;
- max-width: 960px;
+ max-width: 48rem;
width: 90%;
}
```
```
-
+
+
+
```
####4. Create a Column
-A column is a class used for stacking content horizontally. The first margin is removed using the pseudo-class `first-child`.
-
-```
-.column {
- float: left;
- margin-left: 5%;
-}
-
-.column:first-child {
- margin-left: 0;
-}
-```
+With mobile first, columns are `block` level (takes up the full width available) by default. No additional styles needed!
```
-
+
+
+
+
+
+
+
+
+
```
####5. Create Column Sizes
-Add size classes to columns to create a reuseable grid system.
+On larger screens, columns gain `float: left` in order to stack content horizontally. Columns now use padding for gutters, so we no longer need to worry about removing margins.
```
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
```
```
-.column.full {
- width: 100%;
-}
-
-.column.two-thirds {
- width: 65%;
-}
-
-.column.half {
- width: 47.5%;
-}
-
-.column.one-third {
- width: 30%;
-}
-
-.column.one-fourth {
- width: 21.25%;
+@media (min-width: 40rem) {
+ .column {
+ float: left;
+ padding-left: 1rem;
+ padding-right: 1rem;
+ }
+
+ .column.full { width: 100%; }
+ .column.two-thirds { width: 66.7%; }
+ .column.half { width: 50%; }
+ .column.third { width: 33.3%; }
+ .column.fourth { width: 24.95%; }
+ .column.flow-opposite { float: right; }
}
```
####6. Create Rows
-Columns are wrapped in rows to prevent other elements from stacking next to them, otherwise know as clearing issues. Rows are cleared with either a `clearfix` or `overflow: hidden`. This clearfix was created by [Nicolas Gallagher](http://nicolasgallagher.com/micro-clearfix-hack/).
+Columns are wrapped in rows to prevent other elements from stacking next to them, otherwise know as clearing issues. Rows are cleared using the popular `clearfix`, which was created by [Nicolas Gallagher](http://nicolasgallagher.com/micro-clearfix-hack/).
+
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
```
.clearfix:before,
@@ -129,64 +142,53 @@ Columns are wrapped in rows to prevent other elements from stacking next to them
content: " ";
display: table;
}
-
+
.clearfix:after {
clear: both;
}
-
+
.clearfix {
*zoom: 1;
}
```
-```
-.row {
- overflow: hidden;
-}
-```
+#### Flow Opposite
+Add the class `.flow-opposite` to columns where you want content to display first on mobile but appear on the right on larger screens.
```
A simple guide to responsive design. Made by Adam Kaplan.
-
+
-
+
Why bother with responsive?
We want our websites to be useable on all devices by responding to
the user’s behavior, screen size and screen orientation.
@@ -61,17 +59,62 @@
A Fragmented World
-
As of 2013, there are thousands of different devices and screen sizes that browse the
- internet, so it's impossible to design layouts to target them all. Instead, we must take a more fluid approach to
- design.
+
As of 2013, there are thousands
+ of different devices and screen sizes that browse the internet, so it’s impossible to design layouts to target them
+ all. Instead, we must take a more fluid approach to design.
+
+
+
+
+
+
Mobile First
+
The term “mobile first” gets thrown around a lot lately. What it really means is to start with mobile
+ styles and layer on styles optimized for larger screens only as needed. In other words, your mobile styles become
+ the default and you no longer have to override them later. It’s much simpler!
+
+
+
By assuming a flexible but simple layout by default, you can better guard against browsers—with viewports wide
+ and small—that aren’t quite capable of the full responsive layout. “Mobile first” really means “progressive
+ enhancement.”
+ —Ethan Marcotte
+
+
+
+
+
+
+
+
+
+
+
+
+
Min-width Media Queries
+
Introduce layout-specific rules only when you need them. Use min-width to layer complexity on your
+ layout as the viewport widens. It’s easier to have all the media queries nearby, rather than at the end
+ of the stylesheet or in a separate document.
+
+
1
+
Not All Browsers are Created Equal
+
Browsers will render your CSS differently. To avoid this, it’s a good idea to use a modern
+ alternative to a reset like Normalize.css,
+ which will render elements more consistently cross-browser. Remember to include it as-is before your stylesheet.
+
+
+
+
+
+
+
+
2
Add the Viewport Meta Tag
-
Place in the <head> of your HTML. This enables use of media queries for cross-device layouts.
+
Place in the <head> of your HTML. This enables use of media queries for cross-device layouts.
@@ -86,30 +129,30 @@
CSS Box Model
-
It's important to understand the basics, like how elements are generated and behave in the browser, before
+
It’s important to understand the basics, like how elements are generated and behave in the browser, before
diving into responsive web design. The CSS Box Model consists of four distinct parts.
-
-
+
+
Content
The content of the box, where text and images appear.
-
+
Padding
Clears an area around the content.
-
+
Border
A border that goes around the padding.
-
+
Margin
Clears an area around the border.
@@ -120,7 +163,7 @@
-
2
+
3
Use box-sizing: border-box
Place at the top of your CSS file. The * will target all elements on the page.
@@ -128,16 +171,15 @@
-
Your Choice
What was once a bug
- is now widely used CSS property. It basically means you can choose whether or not to include borders and padding in
+ is now a widely used CSS property. It basically means you can choose whether or not to include borders and padding in
the width of your content.
-
+
Without box-sizing: border-box
@@ -155,9 +197,9 @@
-
3
+
4
Create a Container
-
A container holds all elements and controls the page's maximum width. Using a container will make designing for
+
A container holds all elements and controls the page’s maximum width. Using a container will make designing for
responsive easier!
@@ -173,203 +215,196 @@
-
4
+
5
Create a Column
-
A column is a class used for stacking content horizontally. The first margin is removed using the
- pseudo-classfirst-child.
+
With mobile first, columns are block level (takes up the full width available) by default. No
+ additional styles needed!
-
-
+
-
+
.column
+
+
+ .column
+
+
+
+ .column
+
+
+
+ .column
+
-
5
+
6
Create Column Sizes
-
Add size classes to columns to create a reuseable grid system.
-
-
-
-
-
+
On larger screens, columns gain float: left in order to stack content horizontally. Columns now
+ use padding for gutters, so we no longer need to worry about removing margins.
+
+
+
+
+
-
-
-
-
- .column .full
-
-
-
-
-
- .column .two-thirds
-
-
-
- .column .one-third
-
-
-
-
-
- .column .half
-
-
-
- .column .half
-
-
-
-
-
- .column .one-third
-
-
-
- .column .one-third
-
-
-
- .column .one-third
-
-
-
-
-
- .column .one-fourth
-
-
-
- .column .one-fourth
-
-
-
- .column .one-fourth
-
-
-
- .column .one-fourth
-
+
+
+
+
+ .column .full
-
-
-
-
6
-
Create Rows
-
Columns are wrapped in rows to prevent other elements from stacking next to them, otherwise known as clearing
- issues. Rows are cleared with either a clearfix or overflow: hidden. This clearfix was
- created by Nicolas Gallagher:
-
-
-
-
-
-
-
-
-
-
-
- .column .half
-
-
-
- .column .half
-
+
+
+ .column .two-thirds
-
-
- .column .one-third
-
-
-
- .column .one-third
-
-
-
- .column .one-third
-
+
+ .column .third
-
-
-
-
7
-
Add a Mobile Breakpoint
-
If the browser's screen size is within a set range, a media query
- will replace the CSS the browser uses. This is the bread and butter of
- responsive web design.
-
-
-
-
+
+
+ .column .half
+
-
-
-
-
-
- .column .half
-
-
-
- .column .half
-
-
-
-
-
- .column .one-third
-
-
-
- .column .one-third
-
-
-
- .column .one-third
-
-
+
+ .column .half
-
-
-
-
Practice Makes Perfect
-
By following these simple steps, you are on the path to responsive
- web design mastery. Keep practicing and help make the web a better,
- more useable place.
Columns are wrapped in rows to prevent other elements from stacking next to them, otherwise known as clearing
+ issues. Rows are cleared using the popular clearfix, which was created by
+ Nicolas Gallagher.
+
+
+
+
+
+
+
+
+
+
+ .column .half
+
+
+
+ .column .half
+
+
+
+
+
+ .column .half
+
+
+
+ .column .half
+
+
+
+
+
+
+
+
Flow Opposite
+
Add the class .flow-opposite to columns where you want content to display first on mobile but
+ appear on the right on larger screens.
+
+
+
+
+
+
+
+
+
+
+ .column .half .flow-opposite
+
+
+
+ .column .half
+
+
+
+
+
+
+
+
Practice Makes Perfect
+
By following these simple steps, you are on the path to responsive
+ web design mastery. Keep practicing and help make the web a better,
+ more useable place.