├── .gitignore ├── LICENSE.txt ├── bookmarklet.mdown ├── README.md ├── css ├── base.css └── grid.css ├── example.html └── sass └── grid.scss /.gitignore: -------------------------------------------------------------------------------- 1 | css-grid/css/.sass-cache 2 | 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Crowd Favorite, Ltd. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /bookmarklet.mdown: -------------------------------------------------------------------------------- 1 | # Grid Overlay 2 | 3 | ## Description: 4 | 5 | The following is bookmarklet code to help with front end development using the 12 column grid. When activated, it lays a grid over the site, making it easy to check alignment. 6 | 7 | ## To use 8 | 9 | 1) Copy the following code: 10 | 11 | javascript:(function()%7Bvar%20overlay%3Ddocument.getElementById(%22overlay%22)%3Bif(!overlay)%7Bvar%20overlay%3D%22%3Cstyle%3E%23overlay%20%7Bbackground-color:rgba(255,%20142,%20142,%200.23)%3B%20padding-top:%200%3B%20padding-bottom:%200%3B%20position:%20fixed%3B%20top:%200%3B%20bottom:%200%3B%20left:%200%3B%20right:%200%3B%20height:%20100%25%3B%20z-index:%209999%3B%20%7D%20.overlay-row%20%7Bheight:%20100%25%3B%20%7D%20.c-overlay%20%7Bbackground-color:%20rgba(75,%20187,%2022,%200.3)%3B%20height:%20100%25%3B%20%7D%3C/style%3E%3Cdiv%20id%3D%27overlay%27%20class%3D%27grid%27%3E%20%3Cdiv%20class%3D%27overlay-row%20row%27%3E%20%3Cdiv%20class%3D%27c1%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c2%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c3%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c4%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c5%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c6%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c7%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c8%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c9%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c10%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c11%20c-overlay%27%3E%3C/div%3E%20%3Cdiv%20class%3D%27c12%20c-overlay%27%3E%3C/div%3E%20%3C/div%3E%20%3C/div%3E%22%3Bdocument.body.innerHTML%2B%3Doverlay%3B%7Delse%7Bdocument.body.removeChild(overlay)%3B%7D%7D)()%3B 12 | 13 | 2) In the browser of your choice, create a new bookmark, and in the URL field, paste following code. You can name the bookmark whatever you want. 14 | 15 | 3) Click the bookmarklet to toggle the overlay on and off. Keep in mind that the overlat will only work on sites which use the 12 column grid css file. If you see nothing but a green overlay, double check that the css file is actually being loaded. 16 | 17 | 18 | ## Full script (if it's ever needed) 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Purpose 2 | 3 | CSSGrid is an effort to use less classes to achieve a comprehensive and flexible grid. Each element in the grid only requires one class. That means no .first or .last classes anywhere. 4 | 5 | ### Now using SASS 6 | The `grid.css` is compiled from a SASS file, whose variables can be edited on a per-breakpoint basis. Now you can have custom grid widths, grid gutters, and column margins on each media query breakpoint. SASS will do all the heavy lifting for you, just edit `grid.scss`, compile to `grid.css` and go! There's even an option to include an even larger breakpoint in CSSGrid, if your design requires it. Simply change the `$use-lg-breakpoint` to `true` and edit the appropriate variables. 7 | 8 | #### Variables 9 | Make sure the variables that you choose will work with the 12-column grid. For example, a 980px-wide 12-column grid with 20px margins may have an excess of pixels, depending on which column configuration you use. This is most noticeable in Safari when using the bookmarklet and is due to subpixel rounding issues. Use a grid tool, like [gridulator](http://gridulator.com), to help you tweak your grid columns and widths to get even numbers. A 976px-wide 12-column grid with 20px margins won't have excess pixels to worry about. 10 | 11 | ### Getting Started with Rows 12 | 13 | Using CSSGrid is easy. It starts with a wrapper which is called .grid in this example (but you could change it to whatever you'd like). Once you've got the wrapper in place, create divs with a class of .row. Inside each row, create a set of columns for content areas. 14 | 15 | ### Column Classes 16 | 17 | This grid is built on 12 columns and allows you to wrap your content in the desired number of columns. The grid's class names range from .c1 to .c12 for single columns, but spanning multiple columns is as simple as assigning the column span to your class. For example, .c1-4 would span the first four columns and .c5-8 would span the next three. 18 | 19 | CSSGrid is built on a 12 column grid. You can combine columns easily to support your different structures. Each column class is prefixed with a c designator and from there it's a simple matter of choosing the appropriate span of columns (1-n and so on) you'd wish to use. 20 | 21 | Spanning columns is done by simply running numbers together, for example: c1-3 would be a solid div spanning three columns (or 3/12) while c4-5 would be solid div spanning two columns (2/12) wide and appearing after the first three columns. 22 | 23 | ### Nesting 24 | 25 | Nesting is no problem. You can nest elements as deeply as you desire, and they'll just work. Here is an example of a nested content block that spans two columns. 26 | 27 |
28 |
29 |
30 |
31 |
32 | 33 | 34 | ### Offsets 35 | 36 | This latest version of CSSGrid introduces offsets. Previously to offset a content block from the left side, you would need to place an empty div for that column. For example: 37 | 38 |
39 |
40 |
41 | My content here. 42 |
43 |
44 | 45 | would yield an eleven column block of content offset by one column on the left. This syntax still works, but if you'd prefer to keep your markup clear of empty divs, this new method with offsets will achieve the same results: 46 | 47 |
48 |
49 | My content here. 50 |
51 |
52 | 53 | Simply append the offset class with the number of columns to the left you're wanting to offset. n.b. Nested offsets are not supported. 54 | 55 | ### Grid Overlay 56 | 57 | This new version of CSSGrid ships with a bookmarklet overlay to display your grid columns. The overlay is triggered via your bookmarks bar and works based on the column class names, so you can still use the bookmarklet even if you change the size of your grid structure. 58 | 59 | ### Weight 60 | 61 | CSSGrid means less junk in your HTML in favor of a little bit of extra CSS. Even then, CSSGrid weighs in at 8kb with comments and readable styles. 62 | 63 | ### License 64 | 65 | CSSGrid is licensed under the [MIT License](http://opensource.org/licenses/MIT). 66 | -------------------------------------------------------------------------------- /css/base.css: -------------------------------------------------------------------------------- 1 | /* HTML5 ✰ Boilerplate 2 | * ==|== normalize ========================================================== 3 | */ 4 | 5 | article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } 6 | audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } 7 | audio:not([controls]) { display: none; } 8 | [hidden] { display: none; } 9 | 10 | html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } 11 | body { margin: 0; font-size: 13px; line-height: 1.231; } 12 | body, button, input, select, textarea { font-family: sans-serif; color: #222; } 13 | 14 | ::-moz-selection { background: #fe57a1; color: #fff; text-shadow: none; } 15 | ::selection { background: #fe57a1; color: #fff; text-shadow: none; } 16 | 17 | a { color: #00e; } 18 | a:visited { color: #551a8b; } 19 | a:hover { color: #06e; } 20 | a:focus { outline: thin dotted; } 21 | a:hover, a:active { outline: 0; } 22 | 23 | abbr[title] { border-bottom: 1px dotted; } 24 | b, strong { font-weight: bold; } 25 | blockquote { margin: 1em 40px; } 26 | dfn { font-style: italic; } 27 | hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } 28 | ins { background: #ff9; color: #000; text-decoration: none; } 29 | mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; } 30 | pre, code, kbd, samp { font-family: monospace, monospace; _font-family: 'courier new', monospace; font-size: 1em; } 31 | pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } 32 | q { quotes: none; } 33 | q:before, q:after { content: ""; content: none; } 34 | small { font-size: 85%; } 35 | sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } 36 | sup { top: -0.5em; } 37 | sub { bottom: -0.25em; } 38 | ul, ol { margin: 1em 0; padding: 0 0 0 40px; } 39 | dd { margin: 0 0 0 40px; } 40 | nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; } 41 | img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; } 42 | svg:not(:root) { overflow: hidden; } 43 | figure { margin: 0; } 44 | 45 | form { margin: 0; } 46 | fieldset { border: 0; margin: 0; padding: 0; } 47 | label { cursor: pointer; } 48 | legend { border: 0; *margin-left: -7px; padding: 0; } 49 | button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; } 50 | button, input { line-height: normal; *overflow: visible; } 51 | table button, table input { *overflow: auto; } 52 | button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; } 53 | input[type="checkbox"], input[type="radio"] { box-sizing: border-box; } 54 | input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } 55 | input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } 56 | button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } 57 | textarea { overflow: auto; vertical-align: top; resize: vertical; } 58 | input:valid, textarea:valid { } 59 | input:invalid, textarea:invalid { background-color: #f0dddd; } 60 | 61 | table { border-collapse: collapse; border-spacing: 0; } 62 | td { vertical-align: top; } 63 | 64 | /* ==|== example.html classes ======================================== */ 65 | 66 | body { 67 | border-top: 4px solid #9bbfcf; 68 | color: #323232; 69 | font-family: sans-serif; 70 | font-size: 13px; 71 | line-height: 18px; 72 | } 73 | .placeholder { 74 | background: #e0e0e0; 75 | color: #fff; 76 | font-family: sans-serif; 77 | font-size: 14px; 78 | line-height: 36px; 79 | margin-bottom: 18px; 80 | min-height: 36px; 81 | text-align: center; 82 | } 83 | .placeholder:hover { 84 | cursor: crosshair; 85 | opacity: 0.9; 86 | } 87 | .nested { 88 | background: #9bbfcf; 89 | color: #fff; 90 | font-family: sans-serif; 91 | text-align: center; 92 | } 93 | .nested-2x { 94 | background: #c7e2ee; 95 | color: #fff; 96 | font-family: sans-serif; 97 | text-align: center; 98 | } 99 | 100 | 101 | ::selection {background: #e9f3f8;color: #323232;} 102 | ::-moz-selection {background: #e9f3f8;color: #323232;} 103 | img::selection {background: transparent;} 104 | img::-moz-selection {background: transparent;} 105 | body {-webkit-tap-highlight-color: #f5f5f5;} 106 | 107 | 108 | 109 | 110 | /* ==|== non-semantic helper classes ======================================== */ 111 | .ir { display: block; border: 0; text-indent: -999em; overflow: hidden; background-color: transparent; background-repeat: no-repeat; text-align: left; direction: ltr; } 112 | .ir br { display: none; } 113 | .hidden { display: none !important; visibility: hidden; } 114 | .visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } 115 | .visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; } 116 | .invisible { visibility: hidden; } 117 | .clearfix:before, .clearfix:after { content: ""; display: table; } 118 | .clearfix:after { clear: both; } 119 | .clearfix { zoom: 1; } 120 | 121 | 122 | /* ==|== print styles ======================================================= */ 123 | @media print { 124 | * { background: transparent !important; color: black !important; text-shadow: none !important; filter:none !important; -ms-filter: none !important; } 125 | a, a:visited { text-decoration: underline; } 126 | a[href]:after { content: " (" attr(href) ")"; } 127 | abbr[title]:after { content: " (" attr(title) ")"; } 128 | .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } 129 | pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } 130 | thead { display: table-header-group; } 131 | tr, img { page-break-inside: avoid; } 132 | img { max-width: 100% !important; } 133 | @page { margin: 0.5cm; } 134 | p, h2, h3 { orphans: 3; widows: 3; } 135 | h2, h3 { page-break-after: avoid; } 136 | } -------------------------------------------------------------------------------- /css/grid.css: -------------------------------------------------------------------------------- 1 | /* CSSGrid 2 | * https://github.com/crowdfavorite/css-grid 3 | * Version: 2.0.2 4 | * License: http://opensource.org/licenses/mit-license.php */ 5 | /** mixins 6 | -------------------------------------------------- */ 7 | /** grid foundation 8 | -------------------------------------------------- */ 9 | .grid { 10 | margin: 0 auto; } 11 | 12 | /* fluid media */ 13 | .row img, 14 | .row object, 15 | .row embed, 16 | .row video { 17 | max-width: 100%; } 18 | 19 | /* Default Desktop/Tablet Grid 20 | Works fine with older browsers that don't support media queries. */ 21 | .grid { 22 | /* this makes the page wide but keeps content away from the edge */ 23 | padding-left: 0px; 24 | padding-right: 0px; 25 | width: 1048px; } 26 | 27 | .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12, 28 | .c1-2, .c2-3, .c3-4, .c4-5, .c5-6, .c6-7, .c7-8, .c8-9, .c9-10, .c10-11, .c11-12, 29 | .c1-3, .c2-4, .c3-5, .c4-6, .c5-7, .c6-8, .c7-9, .c8-10, .c9-11, .c10-12, 30 | .c1-4, .c2-5, .c3-6, .c4-7, .c5-8, .c6-9, .c7-10, .c8-11, .c9-12, 31 | .c1-5, .c2-6, .c3-7, .c4-8, .c5-9, .c6-10, .c7-11, .c8-12, 32 | .c1-6, .c2-7, .c3-8, .c4-9, .c5-10, .c6-11, .c7-12, 33 | .c1-7, .c2-8, .c3-9, .c4-10, .c5-11, .c6-12, 34 | .c1-8, .c2-9, .c3-10, .c4-11, .c5-12, 35 | .c1-9, .c2-10, .c3-11, .c4-12, 36 | .c1-10, .c2-11, .c3-12, 37 | .c1-11, .c2-12, 38 | .c1-12 { 39 | margin-left: 20px; 40 | display: inline; 41 | float: left; 42 | min-height: 1px; } 43 | 44 | /* 1/12 */ 45 | .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12 { 46 | width: 69px; } 47 | 48 | .offset1 { 49 | margin-left: 109px; } 50 | 51 | [class*=c1-] .offset1:first-child, 52 | [class*=c2-] .offset1:first-child, 53 | [class*=c3-] .offset1:first-child, 54 | [class*=c4-] .offset1:first-child, 55 | [class*=c5-] .offset1:first-child, 56 | [class*=c6-] .offset1:first-child, 57 | [class*=c7-] .offset1:first-child, 58 | [class*=c8-] .offset1:first-child, 59 | [class*=c9-] .offset1:first-child, 60 | [class*=c10-] .offset1:first-child, 61 | [class*=c11-] .offset1:first-child, 62 | [class*=c12-] .offset1:first-child { 63 | margin-left: 89px; } 64 | 65 | /* 2/12 */ 66 | .c1-2, .c2-3, .c3-4, .c4-5, .c5-6, .c6-7, .c7-8, .c8-9, .c9-10, .c10-11, .c11-12 { 67 | width: 158px; } 68 | 69 | .offset2 { 70 | margin-left: 198px; } 71 | 72 | /* 3/12 */ 73 | .c1-3, .c2-4, .c3-5, .c4-6, .c5-7, .c6-8, .c7-9, .c8-10, .c9-11, .c10-12 { 74 | width: 247px; } 75 | 76 | .offset3 { 77 | margin-left: 287px; } 78 | 79 | /* 4/12 */ 80 | .c1-4, .c2-5, .c3-6, .c4-7, .c5-8, .c6-9, .c7-10, .c8-11, .c9-12 { 81 | width: 336px; } 82 | 83 | .offset4 { 84 | margin-left: 376px; } 85 | 86 | /* 5/12 */ 87 | .c1-5, .c2-6, .c3-7, .c4-8, .c5-9, .c6-10, .c7-11, .c8-12 { 88 | width: 425px; } 89 | 90 | .offset5 { 91 | margin-left: 465px; } 92 | 93 | /* 6/12 */ 94 | .c1-6, .c2-7, .c3-8, .c4-9, .c5-10, .c6-11, .c7-12 { 95 | width: 514px; } 96 | 97 | .offset6 { 98 | margin-left: 554px; } 99 | 100 | /* 7/12 */ 101 | .c1-7, .c2-8, .c3-9, .c4-10, .c5-11, .c6-12 { 102 | width: 603px; } 103 | 104 | .offset7 { 105 | margin-left: 643px; } 106 | 107 | /* 8/12 */ 108 | .c1-8, .c2-9, .c3-10, .c4-11, .c5-12 { 109 | width: 692px; } 110 | 111 | .offset8 { 112 | margin-left: 732px; } 113 | 114 | /* 9/12 */ 115 | .c1-9, .c2-10, .c3-11, .c4-12 { 116 | width: 781px; } 117 | 118 | .offset9 { 119 | margin-left: 821px; } 120 | 121 | /* 10/12 */ 122 | .c1-10, .c2-11, .c3-12 { 123 | width: 870px; } 124 | 125 | .offset10 { 126 | margin-left: 910px; } 127 | 128 | /* 11/12 */ 129 | .c1-11, .c2-12 { 130 | width: 959px; } 131 | 132 | .offset11 { 133 | margin-left: 999px; } 134 | 135 | /* 12/12 */ 136 | .c1-12 { 137 | width: 1048px; } 138 | 139 | /* Accounts for extra margin on first column 140 | This value should change a negative margin of whatever your gutter width is. */ 141 | .row { 142 | margin-left: -20px; } 143 | 144 | /* Medium Sized Grid 145 | Tablet sized columns. */ 146 | @media only screen and (min-width: 800px) and (max-width: 1047px) { 147 | .grid { 148 | padding-left: 20px; 149 | padding-right: 20px; 150 | width: 760px; } 151 | 152 | .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12, 153 | .c1-2, .c2-3, .c3-4, .c4-5, .c5-6, .c6-7, .c7-8, .c8-9, .c9-10, .c10-11, .c11-12, 154 | .c1-3, .c2-4, .c3-5, .c4-6, .c5-7, .c6-8, .c7-9, .c8-10, .c9-11, .c10-12, 155 | .c1-4, .c2-5, .c3-6, .c4-7, .c5-8, .c6-9, .c7-10, .c8-11, .c9-12, 156 | .c1-5, .c2-6, .c3-7, .c4-8, .c5-9, .c6-10, .c7-11, .c8-12, 157 | .c1-6, .c2-7, .c3-8, .c4-9, .c5-10, .c6-11, .c7-12, 158 | .c1-7, .c2-8, .c3-9, .c4-10, .c5-11, .c6-12, 159 | .c1-8, .c2-9, .c3-10, .c4-11, .c5-12, 160 | .c1-9, .c2-10, .c3-11, .c4-12, 161 | .c1-10, .c2-11, .c3-12, 162 | .c1-11, .c2-12, 163 | .c1-12 { 164 | display: inline; 165 | /* IE6/IE7 double-margin float bug fix */ 166 | float: left; 167 | margin-left: 20px; 168 | /* Prevent collapsing of empty columns. Min-height prevents collapse 169 | everywhere but IE6. IE6 doesn't collapse empty collumns anyhow, so no need 170 | for a fix there. */ 171 | min-height: 1px; 172 | clear: none; } 173 | 174 | /* 1/12 */ 175 | .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12 { 176 | width: 45px; } 177 | 178 | .offset1 { 179 | margin-left: 85px; } 180 | 181 | [class*=c1-] .offset1:first-child, 182 | [class*=c2-] .offset1:first-child, 183 | [class*=c3-] .offset1:first-child, 184 | [class*=c4-] .offset1:first-child, 185 | [class*=c5-] .offset1:first-child, 186 | [class*=c6-] .offset1:first-child, 187 | [class*=c7-] .offset1:first-child, 188 | [class*=c8-] .offset1:first-child, 189 | [class*=c9-] .offset1:first-child, 190 | [class*=c10-] .offset1:first-child, 191 | [class*=c11-] .offset1:first-child, 192 | [class*=c12-] .offset1:first-child { 193 | margin-left: 65px; } 194 | 195 | /* 2/12 */ 196 | .c1-2, .c2-3, .c3-4, .c4-5, .c5-6, .c6-7, .c7-8, .c8-9, .c9-10, .c10-11, .c11-12 { 197 | width: 110px; } 198 | 199 | .offset2 { 200 | margin-left: 150px; } 201 | 202 | /* 3/12 */ 203 | .c1-3, .c2-4, .c3-5, .c4-6, .c5-7, .c6-8, .c7-9, .c8-10, .c9-11, .c10-12 { 204 | width: 175px; } 205 | 206 | .offset3 { 207 | margin-left: 215px; } 208 | 209 | /* 4/12 */ 210 | .c1-4, .c2-5, .c3-6, .c4-7, .c5-8, .c6-9, .c7-10, .c8-11, .c9-12 { 211 | width: 240px; } 212 | 213 | .offset4 { 214 | margin-left: 280px; } 215 | 216 | /* 5/12 */ 217 | .c1-5, .c2-6, .c3-7, .c4-8, .c5-9, .c6-10, .c7-11, .c8-12 { 218 | width: 305px; } 219 | 220 | .offset5 { 221 | margin-left: 345px; } 222 | 223 | /* 6/12 */ 224 | .c1-6, .c2-7, .c3-8, .c4-9, .c5-10, .c6-11, .c7-12 { 225 | width: 370px; } 226 | 227 | .offset6 { 228 | margin-left: 410px; } 229 | 230 | /* 7/12 */ 231 | .c1-7, .c2-8, .c3-9, .c4-10, .c5-11, .c6-12 { 232 | width: 435px; } 233 | 234 | .offset7 { 235 | margin-left: 475px; } 236 | 237 | /* 8/12 */ 238 | .c1-8, .c2-9, .c3-10, .c4-11, .c5-12 { 239 | width: 500px; } 240 | 241 | .offset8 { 242 | margin-left: 540px; } 243 | 244 | /* 9/12 */ 245 | .c1-9, .c2-10, .c3-11, .c4-12 { 246 | width: 565px; } 247 | 248 | .offset9 { 249 | margin-left: 605px; } 250 | 251 | /* 10/12 */ 252 | .c1-10, .c2-11, .c3-12 { 253 | width: 630px; } 254 | 255 | .offset10 { 256 | margin-left: 670px; } 257 | 258 | /* 11/12 */ 259 | .c1-11, .c2-12 { 260 | width: 695px; } 261 | 262 | .offset11 { 263 | margin-left: 735px; } 264 | 265 | /* 12/12 */ 266 | .c1-12 { 267 | width: 760px; } 268 | 269 | /* Accounts for extra margin on first column 270 | This value should change a negative margin of whatever your gutter width is. */ 271 | .row { 272 | margin-left: -20px; } } 273 | /* Large Desktop Grid 274 | Very wide columns for large monitors. */ 275 | /* Single-column mobile 276 | Get rid of widths and floats, go to fluid single column. */ 277 | @media only screen and (max-width: 799px) { 278 | .grid { 279 | padding-left: 10px; 280 | padding-right: 10px; } 281 | 282 | .grid, 283 | .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12, 284 | .c1-2, .c2-3, .c3-4, .c4-5, .c5-6, .c6-7, .c7-8, .c8-9, .c9-10, .c10-11, .c11-12, 285 | .c1-3, .c2-4, .c3-5, .c4-6, .c5-7, .c6-8, .c7-9, .c8-10, .c9-11, .c10-12, 286 | .c1-4, .c2-5, .c3-6, .c4-7, .c5-8, .c6-9, .c7-10, .c8-11, .c9-12, 287 | .c1-5, .c2-6, .c3-7, .c4-8, .c5-9, .c6-10, .c7-11, .c8-12, 288 | .c1-6, .c2-7, .c3-8, .c4-9, .c5-10, .c6-11, .c7-12, 289 | .c1-7, .c2-8, .c3-9, .c4-10, .c5-11, .c6-12, 290 | .c1-8, .c2-9, .c3-10, .c4-11, .c5-12, 291 | .c1-9, .c2-10, .c3-11, .c4-12, 292 | .c1-10, .c2-11, .c3-12, 293 | .c1-11, .c2-12, 294 | .c1-12 { 295 | display: block; 296 | float: none; 297 | margin-left: 0; 298 | width: auto; } 299 | 300 | .row { 301 | margin-left: 0; } } 302 | /* Zeroing out leftmost nested .unit margins */ 303 | [class*=c1] [class*=c1], 304 | [class*=c2] [class*=c2], 305 | [class*=c3] [class*=c3], 306 | [class*=c4] [class*=c4], 307 | [class*=c5] [class*=c5], 308 | [class*=c6] [class*=c6], 309 | [class*=c7] [class*=c7], 310 | [class*=c8] [class*=c8], 311 | [class*=c9] [class*=c9], 312 | [class*=c10] [class*=c10], 313 | [class*=c11] [class*=c11], 314 | [class*=c12] [class*=c12], 315 | [class*=c1-] .offset1:first-child, 316 | [class*=c2-] .offset1:first-child, 317 | [class*=c3-] .offset1:first-child, 318 | [class*=c4-] .offset1:first-child, 319 | [class*=c5-] .offset1:first-child, 320 | [class*=c6-] .offset1:first-child, 321 | [class*=c7-] .offset1:first-child, 322 | [class*=c8-] .offset1:first-child, 323 | [class*=c9-] .offset1:first-child, 324 | [class*=c10-] .offset1:first-child, 325 | [class*=c11-] .offset1:first-child, 326 | [class*=c12-] .offset1:first-child, 327 | .row .row { 328 | margin-left: 0; } 329 | 330 | /* Full-width */ 331 | .c1-12 { 332 | clear: both; 333 | display: block; 334 | min-height: 1px; } 335 | 336 | /** grid utilities 337 | -------------------------------------------------- */ 338 | /* Row offsetfix 339 | Uses variation of Nicolas Gallagher's Micro offsetfix. 340 | http://nicolasgallagher.com/micro-offsetfix-hack/ */ 341 | .row:before, 342 | .row:after { 343 | content: ""; 344 | display: table; } 345 | 346 | .row:after { 347 | clear: both; } 348 | 349 | .row { 350 | /* Just in case: make sure that rows offset outside floats. */ 351 | clear: both; 352 | /* For IE 6/7 (trigger hasLayout) */ 353 | zoom: 1; } 354 | -------------------------------------------------------------------------------- /example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Crowd Favorite | 12 Column Grid 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 |

CSSGrid

25 |

CSSGrid is an easier-to-use grid. No .first, no .last, just nestable grid slots.

26 | 27 |
28 | 29 |
30 |

Purpose

31 |

CSSGrid is an effort to use less classes to achieve a comprehensive and flexible grid. Each element in the grid only requires one class. That means no .first or .last classes anywhere.

32 |
33 |
34 |

Nesting

35 |

Nesting is no problem. You can nest elements as deeply as you desire, and they'll just work. Just wrap each level of your nested content in a .row class and you’ll be good to go.

36 |
37 |
38 |

Weight

39 |

CSSGrid means less junk in your HTML in favor of a little bit of extra CSS. Even then, CSSGrid weighs in at 5kb with comments and readable styles.

40 |
41 |
42 | 43 |
44 |
45 |

How to Use It

46 |

Using CSSGrid is easy. It starts with a wrapper which is called .grid in this example (but you could change it to whatever you'd like). Once you’ve got the wrapper in place, create divs with a class of .row. Inside each row, create a set of columns for content areas.

47 |
48 |
49 |

Columns

50 |

CSSGrid is built on a 12 column grid. You can combine columns easily to support your different structures. Each column class is prefixed with a c designator and from there it’s a simple amtter of choosing the appropriate span of columns (1-n and so on) you’d wish to use.

51 |

Spanning columns is done by simply running numbers together, for example: c1-3 would be a solid div spanning three columns (or 3/12) while c4-5 would be solid div spanning two columns (2/12) wide and appearing after the first three columns.

52 |
53 |
54 |

License

55 |

CSSGrid is licensed under the MIT License.

56 |
57 | 58 |
59 | 60 | 61 |
62 |
63 |

Let’s See It In Action

64 |

Below is a sample grid to give you an idea of the slot structure, and how combining slots works to create a variety of layouts. Those sections in blue are nested. Darker blue divs are nested one level and lighter blue are two levels deep.

65 |

66 |
67 |
68 | 69 | 70 |
71 |
.c1-4
72 |
73 |
.c5-8
74 |
.c10-11
75 |
76 |
77 | 78 | 79 |
80 |
.c1
81 |
.c2
82 |
.c3
83 |
.c4
84 |
.c5
85 |
.c6
86 |
.c7
87 |
.c8
88 |
.c9
89 |
.c10
90 |
.c11
91 |
.c12
92 |
93 | 94 |
95 |
96 |
97 |
.c1
98 |
99 |
100 |
.c3-4
101 |
.c5-6
102 |
.c7-8
103 |
104 |
105 |
.c9
106 |
.c10
107 |
108 |
109 |
110 |
111 |
.c11-12
112 |
113 |
114 |
115 | 116 |
117 |
.c1-3
118 |
119 |
120 |
.c4
121 |
.c5
122 |
123 |
.c6
124 |
125 |
.c7-9
126 |
.c10-12
127 |
128 | 129 |
130 |
131 |
.c2-3
132 |
133 |
.c5-8
134 |
.c9-12
135 |
136 | 137 |
138 |
.c1
139 |
.c2-4
140 |
.c5-7
141 |
142 |
143 |
.c8
144 |
.c9
145 |
.c10
146 |
147 |
148 |
.c11
149 |
150 |
151 |
.c12
152 |
153 |
154 |
155 | 156 |
157 |
.c1
158 |
159 |
160 |
.c2-4
161 |
.c5
162 |
.c6
163 |
164 |
165 |
166 |
167 |
.c7-8
168 |
.c9-10
169 |
.c11
170 |
171 |
172 |
.c12
173 |
174 | 175 |
176 |
.c1
177 |
.c2
178 |
.c3-6
179 |
.c7-10
180 |
.c11
181 |
.c12
182 |
183 | 184 |
185 |
.c1
186 |
.c2-12
187 |
188 | 189 |
190 |
.c1-2
191 |
192 |
193 |
194 |
195 |
.c3-4
196 |
.c5-8
197 |
.c9
198 |
.c10
199 |
200 |
201 |
.c11
202 |
.c12
203 |
204 |
205 |
206 | 207 |
208 |
.c1-3
209 |
.c4-12
210 |
211 | 212 |
213 |
.c1-4
214 |
.c5-12
215 |
216 | 217 |
218 |
.c1-5
219 |
.c6-12
220 |
221 | 222 |
223 |
.c1-6
224 |
.c7-12
225 |
226 | 227 |
228 |
.c1-7
229 |
.c8-12
230 |
231 | 232 |
233 |
.c1-8
234 |
.c9-12
235 |
236 | 237 |
238 |
.c1-9
239 |
.c10-12
240 |
241 | 242 |
243 |
.c1-10
244 |
.c11-12
245 |
246 | 247 |
248 |
.c1-11
249 |
.c12
250 |
251 | 252 |
253 |
.c1-12
254 |
255 | 256 |
257 |
.c1-3
258 |
.c4-6
259 |
.c7-9
260 |
.c10-12
261 |
262 | 263 | 264 | 265 | 266 |
267 |
268 |
269 |
270 |
271 |
.c1-2
272 |
.c3
273 |
274 |
275 |
276 |
277 |
278 |
279 |
.c5
280 |
281 |
282 |
.c9-12
283 |
284 | 285 |
286 |
.c2-4
287 |
.c7
288 |
.c10-12
289 |
290 | 291 |
292 |
.c4
293 |
.c8-9
294 |
.c12
295 |
296 | 297 |
298 |
.c1
299 |
300 |
301 |
.c4-5
302 |
303 |
304 |
.c7
305 |
.c9-12
306 |
307 | 308 |
309 |
.c2-12
310 |
311 | 312 |
313 |
.c3-12
314 |
315 | 316 |
317 |
.c4-12
318 |
319 | 320 |
321 |
.c5-12
322 |
323 | 324 |
325 |
326 |
327 |
.c7
328 |
.c10-12
329 |
330 |
331 |
332 | 333 |
334 |
335 |
336 |
.c8-10
337 |
338 |
339 |
340 | 341 |
342 |
.c8-12
343 |
344 | 345 |
346 |
.c9-12
347 |
348 | 349 |
350 |
.c10-12
351 |
352 | 353 |
354 |
.c11-12
355 |
356 | 357 |
358 |
.c12
359 |
360 | 361 | 362 | 363 | 364 |
365 | 366 | -------------------------------------------------------------------------------- /sass/grid.scss: -------------------------------------------------------------------------------- 1 | /* CSSGrid 2 | * https://github.com/crowdfavorite/css-grid 3 | * Version: 2.0.2 4 | * License: http://opensource.org/licenses/mit-license.php */ 5 | 6 | // Variables (editable) 7 | $use-lg-breakpoint: false; 8 | 9 | // Large (large desktop) in px 10 | $lg-grid-inner-width: 1420px; 11 | $lg-grid-gutter: 0px; 12 | $lg-col-margins: 20px; 13 | 14 | // Medium (tablet/desktop) in px 15 | $md-grid-inner-width: 1048px; 16 | $md-grid-gutter: 0px; 17 | $md-col-margins: 20px; 18 | 19 | // Small (mobile) in px 20 | $sm-grid-inner-width: 760px; 21 | $sm-grid-gutter: 20px; 22 | $sm-col-margins: 20px; 23 | 24 | // Smallest (block) in px 25 | $xs-grid-gutter: 10px; 26 | 27 | // grid total widths 28 | $lg-grid-total-width: $lg-grid-inner-width + (2 * $lg-grid-gutter); 29 | $md-grid-total-width: $md-grid-inner-width + (2 * $md-grid-gutter); 30 | $sm-grid-total-width: $sm-grid-inner-width + (2 * $sm-grid-gutter); 31 | 32 | // media queries 33 | $desktop-mq: '(min-width: #{$lg-grid-total-width + 30 })'; 34 | $tablet-mq: '(min-width: #{$sm-grid-total-width}) and (max-width: #{$md-grid-total-width - 1})'; 35 | $phone-mq: '(max-width: #{$sm-grid-total-width - 1})'; 36 | 37 | 38 | // Variables (don't edit) 39 | $column-count: 12; 40 | 41 | // column widths 42 | $lg-column-width: (($lg-grid-inner-width - (($lg-col-margins * ($column-count - 1)))) / $column-count); 43 | $md-column-width: (($md-grid-inner-width - (($md-col-margins * ($column-count - 1)))) / $column-count); 44 | $sm-column-width: (($sm-grid-inner-width - (($sm-col-margins * ($column-count - 1)))) / $column-count); 45 | 46 | /** mixins 47 | -------------------------------------------------- */ 48 | @mixin gutters($gutter) { 49 | padding-left: $gutter; 50 | padding-right: $gutter; 51 | } 52 | 53 | @mixin width($col-width, $margin-width, $multiplier: 1) { 54 | width: (($col-width * $multiplier) + (($multiplier - 1) * $margin-width)); 55 | } 56 | 57 | @mixin offset($col-width, $margin-width, $multiplier: 1, $first: false) { 58 | @if $first { 59 | margin-left: (($col-width * $multiplier) + ($multiplier * $margin-width)); 60 | } 61 | @else { 62 | margin-left: (($col-width * $multiplier) + ($multiplier * $margin-width) + $margin-width); 63 | } 64 | } 65 | 66 | @mixin row($margin) { 67 | margin-left: -$margin; 68 | } 69 | 70 | /** grid foundation 71 | -------------------------------------------------- */ 72 | .grid { 73 | margin: 0 auto; 74 | } 75 | 76 | /* fluid media */ 77 | .row img, 78 | .row object, 79 | .row embed, 80 | .row video { 81 | max-width: 100%; 82 | } 83 | 84 | /* Default Desktop/Tablet Grid 85 | Works fine with older browsers that don't support media queries. */ 86 | .grid { 87 | /* this makes the page wide but keeps content away from the edge */ 88 | @include gutters($md-grid-gutter); 89 | width: $md-grid-inner-width; 90 | } 91 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12, 92 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12, 93 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12, 94 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12, 95 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12, 96 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12, 97 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12, 98 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12, 99 | .c1-9,.c2-10,.c3-11,.c4-12, 100 | .c1-10,.c2-11,.c3-12, 101 | .c1-11,.c2-12, 102 | .c1-12 { 103 | margin-left: $md-col-margins; 104 | display: inline; 105 | float: left; 106 | min-height: 1px; 107 | } 108 | 109 | /* 1/12 */ 110 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12 { @include width($md-column-width, $md-col-margins); } 111 | .offset1 { @include offset($md-column-width, $md-col-margins); } 112 | [class*=c1-], 113 | [class*=c2-], 114 | [class*=c3-], 115 | [class*=c4-], 116 | [class*=c5-], 117 | [class*=c6-], 118 | [class*=c7-], 119 | [class*=c8-], 120 | [class*=c9-], 121 | [class*=c10-], 122 | [class*=c11-], 123 | [class*=c12-] { 124 | .offset1:first-child { 125 | @include offset($md-column-width, $md-col-margins, 1, true); 126 | } 127 | } 128 | /* 2/12 */ 129 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12 { @include width($md-column-width, $md-col-margins, 2); } 130 | .offset2 { @include offset($md-column-width, $md-col-margins, 2); } 131 | /* 3/12 */ 132 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12 { @include width($md-column-width, $md-col-margins, 3); } 133 | .offset3 { @include offset($md-column-width, $md-col-margins, 3); } 134 | /* 4/12 */ 135 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12 { @include width($md-column-width, $md-col-margins, 4); } 136 | .offset4 { @include offset($md-column-width, $md-col-margins, 4); } 137 | /* 5/12 */ 138 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12 { @include width($md-column-width, $md-col-margins, 5); } 139 | .offset5 { @include offset($md-column-width, $md-col-margins, 5); } 140 | /* 6/12 */ 141 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12 { @include width($md-column-width, $md-col-margins, 6); } 142 | .offset6 { @include offset($md-column-width, $md-col-margins, 6); } 143 | /* 7/12 */ 144 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12 { @include width($md-column-width, $md-col-margins, 7); } 145 | .offset7 { @include offset($md-column-width, $md-col-margins, 7); } 146 | /* 8/12 */ 147 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12 { @include width($md-column-width, $md-col-margins, 8); } 148 | .offset8 { @include offset($md-column-width, $md-col-margins, 8); } 149 | /* 9/12 */ 150 | .c1-9,.c2-10,.c3-11,.c4-12 { @include width($md-column-width, $md-col-margins, 9); } 151 | .offset9 { @include offset($md-column-width, $md-col-margins, 9); } 152 | /* 10/12 */ 153 | .c1-10,.c2-11,.c3-12 { @include width($md-column-width, $md-col-margins, 10); } 154 | .offset10 { @include offset($md-column-width, $md-col-margins, 10); } 155 | /* 11/12 */ 156 | .c1-11,.c2-12 { @include width($md-column-width, $md-col-margins, 11); } 157 | .offset11 { @include offset($md-column-width, $md-col-margins, 11); } 158 | /* 12/12 */ 159 | .c1-12 { @include width($md-column-width, $md-col-margins, 12); } 160 | /* Accounts for extra margin on first column 161 | This value should change a negative margin of whatever your gutter width is. */ 162 | .row { 163 | @include row($md-col-margins); 164 | } 165 | 166 | 167 | /* Medium Sized Grid 168 | Tablet sized columns. */ 169 | @media only screen and #{$tablet-mq} { 170 | .grid { 171 | @include gutters($sm-grid-gutter); 172 | width: $sm-grid-inner-width; 173 | } 174 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12, 175 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12, 176 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12, 177 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12, 178 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12, 179 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12, 180 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12, 181 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12, 182 | .c1-9,.c2-10,.c3-11,.c4-12, 183 | .c1-10,.c2-11,.c3-12, 184 | .c1-11,.c2-12, 185 | .c1-12 { 186 | display: inline; /* IE6/IE7 double-margin float bug fix */ 187 | float: left; 188 | margin-left: $sm-col-margins; 189 | /* Prevent collapsing of empty columns. Min-height prevents collapse 190 | everywhere but IE6. IE6 doesn't collapse empty collumns anyhow, so no need 191 | for a fix there. */ 192 | min-height: 1px; 193 | clear: none; 194 | } 195 | /* 1/12 */ 196 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12 { @include width($sm-column-width, $sm-col-margins); } 197 | .offset1 { @include offset($sm-column-width, $sm-col-margins); } 198 | [class*=c1-], 199 | [class*=c2-], 200 | [class*=c3-], 201 | [class*=c4-], 202 | [class*=c5-], 203 | [class*=c6-], 204 | [class*=c7-], 205 | [class*=c8-], 206 | [class*=c9-], 207 | [class*=c10-], 208 | [class*=c11-], 209 | [class*=c12-] { 210 | .offset1:first-child { 211 | @include offset($sm-column-width, $sm-col-margins, 1, true); 212 | } 213 | } 214 | /* 2/12 */ 215 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12 { @include width($sm-column-width, $sm-col-margins, 2); } 216 | .offset2 { @include offset($sm-column-width, $sm-col-margins, 2); } 217 | /* 3/12 */ 218 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12 { @include width($sm-column-width, $sm-col-margins, 3); } 219 | .offset3 { @include offset($sm-column-width, $sm-col-margins, 3); } 220 | /* 4/12 */ 221 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12 { @include width($sm-column-width, $sm-col-margins, 4); } 222 | .offset4 { @include offset($sm-column-width, $sm-col-margins, 4); } 223 | /* 5/12 */ 224 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12 { @include width($sm-column-width, $sm-col-margins, 5); } 225 | .offset5 { @include offset($sm-column-width, $sm-col-margins, 5); } 226 | /* 6/12 */ 227 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12 { @include width($sm-column-width, $sm-col-margins, 6); } 228 | .offset6 { @include offset($sm-column-width, $sm-col-margins, 6); } 229 | /* 7/12 */ 230 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12 { @include width($sm-column-width, $sm-col-margins, 7); } 231 | .offset7 { @include offset($sm-column-width, $sm-col-margins, 7); } 232 | /* 8/12 */ 233 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12 { @include width($sm-column-width, $sm-col-margins, 8); } 234 | .offset8 { @include offset($sm-column-width, $sm-col-margins, 8); } 235 | /* 9/12 */ 236 | .c1-9,.c2-10,.c3-11,.c4-12 { @include width($sm-column-width, $sm-col-margins, 9); } 237 | .offset9 { @include offset($sm-column-width, $sm-col-margins, 9); } 238 | /* 10/12 */ 239 | .c1-10,.c2-11,.c3-12 { @include width($sm-column-width, $sm-col-margins, 10); } 240 | .offset10 { @include offset($sm-column-width, $sm-col-margins, 10); } 241 | /* 11/12 */ 242 | .c1-11,.c2-12 { @include width($sm-column-width, $sm-col-margins, 11); } 243 | .offset11 { @include offset($sm-column-width, $sm-col-margins, 11); } 244 | /* 12/12 */ 245 | .c1-12 { @include width($sm-column-width, $sm-col-margins, 12); } 246 | 247 | /* Accounts for extra margin on first column 248 | This value should change a negative margin of whatever your gutter width is. */ 249 | .row { 250 | @include row($sm-col-margins); 251 | } 252 | } 253 | 254 | 255 | /* Large Desktop Grid 256 | Very wide columns for large monitors. */ 257 | 258 | @if $use-lg-breakpoint { 259 | @media only screen and #{$desktop-mq} { 260 | .grid { 261 | @include gutters($lg-grid-gutter); 262 | width: $lg-grid-inner-width; 263 | } 264 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12, 265 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12, 266 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12, 267 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12, 268 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12, 269 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12, 270 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12, 271 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12, 272 | .c1-9,.c2-10,.c3-11,.c4-12, 273 | .c1-10,.c2-11,.c3-12, 274 | .c1-11,.c2-12, 275 | .c1-12 { 276 | margin-left: $lg-col-margins; 277 | display: inline; 278 | float: left; 279 | min-height: 1px; 280 | } 281 | 282 | /* 1/12 */ 283 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12 { @include width($lg-column-width, $lg-col-margins); } 284 | .offset1 { @include offset($lg-column-width, $lg-col-margins); } 285 | [class*=c1-], 286 | [class*=c2-], 287 | [class*=c3-], 288 | [class*=c4-], 289 | [class*=c5-], 290 | [class*=c6-], 291 | [class*=c7-], 292 | [class*=c8-], 293 | [class*=c9-], 294 | [class*=c10-], 295 | [class*=c11-], 296 | [class*=c12-] { 297 | .offset1:first-child { 298 | @include offset($lg-column-width, $lg-col-margins, 1, true); 299 | } 300 | } 301 | /* 2/12 */ 302 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12 { @include width($lg-column-width, $lg-col-margins, 2); } 303 | .offset2 { @include offset($lg-column-width, $lg-col-margins, 2); } 304 | /* 3/12 */ 305 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12 { @include width($lg-column-width, $lg-col-margins, 3); } 306 | .offset3 { @include offset($lg-column-width, $lg-col-margins, 3); } 307 | /* 4/12 */ 308 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12 { @include width($lg-column-width, $lg-col-margins, 4); } 309 | .offset4 { @include offset($lg-column-width, $lg-col-margins, 4); } 310 | /* 5/12 */ 311 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12 { @include width($lg-column-width, $lg-col-margins, 5); } 312 | .offset5 { @include offset($lg-column-width, $lg-col-margins, 5); } 313 | /* 6/12 */ 314 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12 { @include width($lg-column-width, $lg-col-margins, 6); } 315 | .offset6 { @include offset($lg-column-width, $lg-col-margins, 6); } 316 | /* 7/12 */ 317 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12 { @include width($lg-column-width, $lg-col-margins, 7); } 318 | .offset7 { @include offset($lg-column-width, $lg-col-margins, 7); } 319 | /* 8/12 */ 320 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12 { @include width($lg-column-width, $lg-col-margins, 8); } 321 | .offset8 { @include offset($lg-column-width, $lg-col-margins, 8); } 322 | /* 9/12 */ 323 | .c1-9,.c2-10,.c3-11,.c4-12 { @include width($lg-column-width, $lg-col-margins, 9); } 324 | .offset9 { @include offset($lg-column-width, $lg-col-margins, 9); } 325 | /* 10/12 */ 326 | .c1-10,.c2-11,.c3-12 { @include width($lg-column-width, $lg-col-margins, 10); } 327 | .offset10 { @include offset($lg-column-width, $lg-col-margins, 10); } 328 | /* 11/12 */ 329 | .c1-11,.c2-12 { @include width($lg-column-width, $lg-col-margins, 11); } 330 | .offset11 { @include offset($lg-column-width, $lg-col-margins, 11); } 331 | /* 12/12 */ 332 | .c1-12 { @include width($lg-column-width, $lg-col-margins, 12); } 333 | 334 | /* Accounts for extra margin on first column 335 | This value should change a negative margin of whatever your gutter width is. */ 336 | .row { 337 | @include row($lg-col-margins); 338 | } 339 | } 340 | } 341 | 342 | /* Single-column mobile 343 | Get rid of widths and floats, go to fluid single column. */ 344 | @media only screen and #{$phone-mq} { 345 | .grid { 346 | @include gutters($xs-grid-gutter); 347 | } 348 | 349 | .grid, 350 | .c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12, 351 | .c1-2,.c2-3,.c3-4,.c4-5,.c5-6,.c6-7,.c7-8,.c8-9,.c9-10,.c10-11,.c11-12, 352 | .c1-3,.c2-4,.c3-5,.c4-6,.c5-7,.c6-8,.c7-9,.c8-10,.c9-11,.c10-12, 353 | .c1-4,.c2-5,.c3-6,.c4-7,.c5-8,.c6-9,.c7-10,.c8-11,.c9-12, 354 | .c1-5,.c2-6,.c3-7,.c4-8,.c5-9,.c6-10,.c7-11,.c8-12, 355 | .c1-6,.c2-7,.c3-8,.c4-9,.c5-10,.c6-11,.c7-12, 356 | .c1-7,.c2-8,.c3-9,.c4-10,.c5-11,.c6-12, 357 | .c1-8,.c2-9,.c3-10,.c4-11,.c5-12, 358 | .c1-9,.c2-10,.c3-11,.c4-12, 359 | .c1-10,.c2-11,.c3-12, 360 | .c1-11,.c2-12, 361 | .c1-12 { 362 | display: block; 363 | float: none; 364 | margin-left: 0; 365 | width: auto; 366 | } 367 | .row { 368 | margin-left: 0; 369 | } 370 | } 371 | 372 | /* Zeroing out leftmost nested .unit margins */ 373 | [class*=c1] [class*=c1], 374 | [class*=c2] [class*=c2], 375 | [class*=c3] [class*=c3], 376 | [class*=c4] [class*=c4], 377 | [class*=c5] [class*=c5], 378 | [class*=c6] [class*=c6], 379 | [class*=c7] [class*=c7], 380 | [class*=c8] [class*=c8], 381 | [class*=c9] [class*=c9], 382 | [class*=c10] [class*=c10], 383 | [class*=c11] [class*=c11], 384 | [class*=c12] [class*=c12], 385 | [class*=c1-] .offset1:first-child, 386 | [class*=c2-] .offset1:first-child, 387 | [class*=c3-] .offset1:first-child, 388 | [class*=c4-] .offset1:first-child, 389 | [class*=c5-] .offset1:first-child, 390 | [class*=c6-] .offset1:first-child, 391 | [class*=c7-] .offset1:first-child, 392 | [class*=c8-] .offset1:first-child, 393 | [class*=c9-] .offset1:first-child, 394 | [class*=c10-] .offset1:first-child, 395 | [class*=c11-] .offset1:first-child, 396 | [class*=c12-] .offset1:first-child, 397 | .row .row { 398 | margin-left: 0; 399 | } 400 | 401 | /* Full-width */ 402 | .c1-12 { 403 | clear: both; 404 | display: block; 405 | min-height: 1px; 406 | } 407 | 408 | /** grid utilities 409 | -------------------------------------------------- */ 410 | /* Row offsetfix 411 | Uses variation of Nicolas Gallagher's Micro offsetfix. 412 | http://nicolasgallagher.com/micro-offsetfix-hack/ */ 413 | .row:before, 414 | .row:after { 415 | content:""; 416 | display:table; 417 | } 418 | .row:after { 419 | clear:both; 420 | } 421 | .row { 422 | /* Just in case: make sure that rows offset outside floats. */ 423 | clear: both; 424 | /* For IE 6/7 (trigger hasLayout) */ 425 | zoom:1; 426 | } 427 | --------------------------------------------------------------------------------