Skip to content

Instantly share code, notes, and snippets.

@danieldogeanu
Created October 21, 2013 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieldogeanu/7087105 to your computer and use it in GitHub Desktop.
Save danieldogeanu/7087105 to your computer and use it in GitHub Desktop.
Responsive Design & Flexible Values: Formula
target : context = result
For ems (fonts):
ex:
body {
font-size: 100%;
}
h1 {
font-size: 24px;
}
*default baseline is 16px
24 : 16 = 1.5
The new heading is now 1.5em:
h1 {
font-size: 1.5em;
}
For percentages (layouts):
ex:
.wrapper {
width: 1000px;
}
article {
float: left;
width: 700px;
}
aside {
float: right;
width: 300px;
}
*the same formula, but now after we get the result, we move the decimal dot two digits to the right
article: 700 : 1000 = 0.7 => move the dot and we get: 70%
aside: 300 : 1000 = 0.3 => move the dot and we get: 30%
The new layout is now:
.wrapper {
width: 1000px;
}
article {
float: left;
width: 70%;
}
aside {
float: right;
width: 30%;
}
*please note: the wrapper is not flexible at this point, this is just to grasp the concept of flexible percentage values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment