├── README.md ├── bower.json ├── css ├── grid.css └── normalize.css ├── images ├── border.png ├── box-model.png ├── container.png ├── content.png ├── desktop-first.png ├── fragmentation.png ├── margin.png ├── mobile-first.png ├── mobile.png ├── padding.png ├── small-large.png ├── with-box-model.png └── without-box-model.png └── index.html /README.md: -------------------------------------------------------------------------------- 1 | ##Grid 2 | 3 | Um guia simples para design responsivo.
4 | webfatorial.github.io/grid/ 5 | 6 | ####Por que se importar com responsivo? 7 | Queremos que nossos sites sejam usáveis em todos os dispositivos, respondendo ao comportamento e tamanho e orientação de tela do visitante. 8 | 9 | ####Um mundo fragmentado 10 | Desde 2013 existem milhares de diferentes dispositivos e tamanhos de tela que acessam a internet, tornando impossível projetar layouts para todos. Ao invés disso, precisamos adotar uma abordagem mais fluida ao design. 11 | 12 | ####Mobile First 13 | O termo "mobile first" (móvel primeiro) tem aparecido bastante ultimamente. O que isso realmente significa é começar com os estilos para mobile e ir avançando em estilos otimizados para telas maiores apenas quando necessário. Em outras palavras, seus estilos para dispositivos móveis se tornam o padrão e você não os precisa mais sobrescrever depois. é muito mais simples! 14 | 15 | > Assumindo um layout flexível, mas simples, por padrão, você pode melhor se resguardar contra navegadores — com viewports pequenas e grandes — que não são totalmente capazes em relação a layout responsivo. Então, quando falamos sobre layout, "mobile first" realmente significa "progressive enhancement" (melhoramento progressivo). 16 | 17 | ##Media queries com min-width 18 | Introduza regras específicas ao layout somente quando precisar delas. Use `min-width` para lidar com complexidade à medida em que a viewport se torna maior. É mais fácil ter todas as media queries próximas ao invés de no final da folha de estilos ou em documento separado. 19 | 20 | ```css 21 | /* Small screens (default) */ 22 | html { font-size: 100%; } 23 | 24 | /* Medium screens (640px) */ 25 | @media (min-width: 40rem) { 26 | html { font-size: 112%; } 27 | } 28 | 29 | /* Large screens (1024px) */ 30 | @media (min-width: 64rem) { 31 | html { font-size: 120%; } 32 | } 33 | ``` 34 | 35 | ##Passos 36 | 37 | ####1. Nem todos os navegadores são iguais 38 | Navegadores irão renderizar seu CSS de maneira diferente. Para evitar isso, é uma boa ideia usar uma alternativa moderna ao reset, como [Normalize.css](http://necolas.github.io/normalize.css/), que irá renderizar seus elementos mais consistentemente entre os navegadores (cross-browser). Lembre-se de incluí-lo antes de sua folha de estilos. 39 | 40 | ```html 41 | 42 | 43 | ``` 44 | 45 | ####2. Adicione a meta tag Viewport 46 | Coloque na `` de seu HTML. Isso habilita o uso de media queries para layouts cross-device. 47 | 48 | ```html 49 | 50 | ``` 51 | 52 | ####3. Use box-sizing: border-box 53 | Coloque no início de seu arquivo CSS. O `*` vai afetar todos os elementos na página. 54 | 55 | ```css 56 | *, *:before, *:after { 57 | -moz-box-sizing: border-box; 58 | -webkit-box-sizing: border-box; 59 | box-sizing: border-box; 60 | } 61 | ``` 62 | 63 | ####4. Crie um contêiner 64 | Um contêiner detém todos os elementos e controla a largura máxima da página. Usando um contêiner você faz de projetos de design responsivo mais fáceis! 65 | 66 | ```css 67 | .container { 68 | margin: 0 auto; 69 | max-width: 48rem; 70 | width: 90%; 71 | } 72 | ``` 73 | 74 | ```html 75 |
76 | 77 |
78 | ``` 79 | 80 | ####5. Crie uma coluna 81 | Com mobile first, colunas são nível de bloco (`block`), por padrão tomando a largura total disponível. Nenhum estilo adicional é necessário! 82 | 83 | ```html 84 |
85 |
86 | 87 |
88 |
89 | ``` 90 | 91 | ####6. Crie tamanhos de colunas 92 | Em telas grandes, colunas obtêm `float: left` a fim de "empilhar" (stack) o conteúdo horizontalmente. Colunas agora usam padding para espaçamento, então você não precisa mais se preocupar em remover margens. 93 | 94 | ```html 95 |
96 |
97 |
98 | 99 |
100 |
101 | 102 |
103 |
104 |
105 | ``` 106 | 107 | ```css 108 | @media (min-width: 40rem) { 109 | .column { 110 | float: left; 111 | padding-left: 1rem; 112 | padding-right: 1rem; 113 | } 114 | 115 | .column.full { width: 100%; } 116 | .column.two-thirds { width: 66.7%; } 117 | .column.half { width: 50%; } 118 | .column.third { width: 33.3%; } 119 | .column.fourth { width: 24.95%; } 120 | .column.flow-opposite { float: right; } 121 | } 122 | ``` 123 | 124 | ####7. Crie linhas 125 | Colunas são envoltas em linhas para evitar que outros elementos fiquem "empilhados" (stacking) próximo a elas, isso também conhecido como "questões de limpeza" (clearing issues). Linhas recebem clear usando o popular `clearfix`, criado por [Nicolas Gallagher](http://nicolasgallagher.com/micro-clearfix-hack/). 126 | 127 | ```html 128 |
129 |
130 |
131 | 132 |
133 |
134 | 135 |
136 |
137 | 138 |
139 |
140 | 141 |
142 |
143 | 144 |
145 |
146 |
147 | ``` 148 | 149 | ```css 150 | .clearfix:before, 151 | .clearfix:after { 152 | content: " "; 153 | display: table; 154 | } 155 | 156 | .clearfix:after { 157 | clear: both; 158 | } 159 | 160 | .clearfix { 161 | *zoom: 1; 162 | } 163 | ``` 164 | 165 | #### Fluxo oposto 166 | Adicione a classe `.flow-opposite` em colunas nas quais você quer o conteúdo apareça primeiro em mobile, mas apareçam à direita em telas maiores. 167 | 168 | ```html 169 |
170 |
171 |
172 | 173 |
174 |
175 | 176 |
177 |
178 |
179 | ``` 180 | 181 | ```css 182 | @media (min-width: 40rem) { 183 | .column.flow-opposite { float: right; } 184 | } 185 | ``` 186 | 187 | ####Leitura Complementar 188 | * [A Book Apart: Mobile First](http://www.abookapart.com/products/mobile-first) 189 | * [A Book Apart: Responsive Web Design](http://www.abookapart.com/products/responsive-web-design) 190 | * [Beginner’s Guide to Responsive Web Design](http://blog.teamtreehouse.com/beginners-guide-to-responsive-web-design) 191 | * [Box-sizing: Border-box FTW](http://www.paulirish.com/2012/box-sizing-border-box-ftw/) 192 | * [Don't Forget the Viewport Meta Tag](http://dev.tutsplus.com/articles/quick-tip-dont-forget-the-viewport-meta-tag--webdesign-5972) 193 | * [The Many Faces of ‘Mobile First’](http://bradfrostweb.com/blog/mobile/the-many-faces-of-mobile-first/) 194 | * [Understanding the Humble Clearfix](http://fuseinteractive.ca/blog/understanding-humble-clearfix) 195 | 196 | ####Referências 197 | * [Android Fragmentation Visualized](http://opensignal.com/reports/fragmentation-2013/) 198 | * [Animate.css](http://daneden.github.io/animate.css/) 199 | * [Box Model](http://developer.mozilla.org/en-US/docs/Web/CSS/box_model) 200 | * [Chrome Developer Tools](http://developers.google.com/chrome-developer-tools/) 201 | * [Code samples by GitHub Gist](https://gist.github.com/aekaplan) 202 | * [Internet Explorer Box Model](http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug) 203 | * [Progressive Enhancement](http://coding.smashingmagazine.com/2009/04/22/progressive-enhancement-what-it-is-and-how-to-use-it/) 204 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aekaplan-grid", 3 | "version": "1.0.0", 4 | "main": "grid.css", 5 | "author": "Adam Kaplan", 6 | "ignore": [ 7 | "README.md", 8 | "index.html" 9 | ] 10 | } -------------------------------------------------------------------------------- /css/grid.css: -------------------------------------------------------------------------------- 1 | /* Layout 2 | ========================================================================== */ 3 | 4 | *, *:before, *:after { 5 | -moz-box-sizing: border-box; 6 | -webkit-box-sizing: border-box; 7 | box-sizing: border-box; 8 | } 9 | 10 | html { 11 | font: 100%/1.5 "Open Sans", sans-serif; 12 | font-weight: 400; 13 | text-rendering: optimizeLegibility; 14 | -webkit-font-smoothing: antialiased; 15 | } 16 | 17 | @media (min-width: 40rem) { 18 | html { font-size: 112%; } 19 | } 20 | 21 | @media (min-width: 64rem) { 22 | html { font-size: 120%; } 23 | } 24 | 25 | body { 26 | background-color: #fff; 27 | color: #555; 28 | } 29 | 30 | .container { 31 | margin: 0 auto; 32 | max-width: 53rem; 33 | width: 90%; 34 | } 35 | 36 | /* Header 37 | ========================================================================== */ 38 | 39 | header { 40 | background-color: #497bad; 41 | text-align: center; 42 | } 43 | 44 | .intro { margin: 2rem 0; } 45 | 46 | @media (min-width: 40rem) { 47 | .intro { margin: 4rem 0; } 48 | } 49 | 50 | header h1 { 51 | border: 3px solid #fff; 52 | -moz-border-radius: 3px; 53 | -webkit-border-radius: 3px; 54 | border-radius: 3px; 55 | color: #fff; 56 | padding: .4rem .6rem; 57 | display: inline-block; 58 | font-size: 1.8rem; 59 | text-transform: uppercase; 60 | margin-bottom: 2rem; 61 | } 62 | 63 | header p { 64 | color: rgba(255,255,255,0.7); 65 | margin: 0 auto; 66 | } 67 | 68 | header a { 69 | color: rgba(255,255,255,0.9); 70 | text-decoration: underline; 71 | } 72 | 73 | header a:hover { text-decoration: none; } 74 | 75 | .mobile { 76 | margin: 0 auto; 77 | max-width: 150px; 78 | } 79 | 80 | @media (min-width: 40rem) { 81 | .mobile { max-width: 250px; } 82 | } 83 | 84 | /* Section 85 | ========================================================================== */ 86 | 87 | section { 88 | border-top: 1px solid #eee; 89 | text-align: center; 90 | padding: 2rem 0; 91 | } 92 | 93 | section:first-of-type { border-top: none; } 94 | 95 | @media (min-width: 40rem) { 96 | section { padding: 4rem 0; } 97 | } 98 | 99 | /* Mobile First Grid 100 | ========================================================================== */ 101 | 102 | .column { margin-bottom: 1.5rem; } 103 | 104 | @media (min-width: 40rem) { 105 | .column { 106 | float: left; 107 | margin: 0; 108 | padding-left: 1rem; 109 | padding-right: 1rem; 110 | } 111 | 112 | .column.full { width: 100%; } 113 | .column.two-thirds { width: 66.7%; } 114 | .column.half { width: 50%; } 115 | .column.third { width: 33.3%; } 116 | .column.fourth { width: 24.95%; } 117 | .column.flow-opposite { float: right; } 118 | } 119 | 120 | /* Typography 121 | ========================================================================== */ 122 | 123 | h1, h2, h3, h4, h5 { 124 | font-weight: 600; 125 | margin: 0; 126 | } 127 | 128 | h1 { 129 | font-size: 1.3rem; 130 | line-height: 1.3em; 131 | margin-bottom: 1.5rem; 132 | } 133 | 134 | @media (min-width: 40rem) { 135 | h1 { font-size: 1.5rem; } 136 | } 137 | 138 | h3 { 139 | font-size: 1.2rem; 140 | margin-bottom: .5rem; 141 | } 142 | 143 | p { 144 | color: #999; 145 | margin: 0 auto; 146 | max-width: 30rem; 147 | } 148 | 149 | blockquote { margin: 0; } 150 | 151 | blockquote p { 152 | color: #bbb; 153 | font-style: italic; 154 | margin-bottom: 1.5rem; 155 | } 156 | 157 | cite { color: #bbb; } 158 | 159 | /* Code 160 | ========================================================================== */ 161 | 162 | code { 163 | background-color: #f8f8f8; 164 | -moz-border-radius: 3px; 165 | -webkit-border-radius: 3px; 166 | border-radius: 3px; 167 | border: 1px solid #ddd; 168 | font-family: Consolas, "Liberation Mono", Courier, monospace; 169 | font-size: 0.8rem; 170 | padding: 0.1rem 0.3rem; 171 | position: relative; 172 | top: -1px; 173 | white-space: nowrap; 174 | } 175 | 176 | /* Lists 177 | ========================================================================== */ 178 | 179 | ul { 180 | margin: 0; 181 | text-align: left; 182 | } 183 | 184 | @media (min-width: 40rem) { 185 | ul { display: inline-block; } 186 | } 187 | 188 | /* Links 189 | ========================================================================== */ 190 | 191 | a { 192 | color: #497bad; 193 | text-decoration: none; 194 | } 195 | 196 | a:hover { text-decoration: underline; } 197 | 198 | /* Buttons 199 | ========================================================================== */ 200 | 201 | .button { 202 | -moz-appearance: none; 203 | -webkit-appearance: none; 204 | appearance: none; 205 | background-color: #497bad; 206 | -moz-border-radius: 3px; 207 | -webkit-border-radius: 3px; 208 | border-radius: 3px; 209 | border: none; 210 | color: #fff; 211 | cursor: pointer; 212 | display: block; 213 | font-size: 1rem; 214 | font-weight: 600; 215 | padding: 0.7rem 1.5rem; 216 | vertical-align: middle; 217 | white-space: nowrap; 218 | } 219 | 220 | .button:hover { 221 | background: #5183b6; 222 | text-decoration: none; 223 | } 224 | 225 | @media (min-width: 40rem) { 226 | .button { 227 | display: inline-block; 228 | font-size: 0.9rem; 229 | } 230 | } 231 | 232 | /* Elements 233 | ========================================================================== */ 234 | 235 | hr { 236 | border: 0; 237 | border-top: 1px solid #ddd; 238 | margin: 2rem auto; 239 | width: 3rem; 240 | } 241 | 242 | @media (min-width: 40rem) { 243 | hr { margin: 2.5rem auto; } 244 | } 245 | 246 | hr.small { margin: 1.5rem auto; } 247 | 248 | .circle { 249 | border: 3px solid #555; 250 | border-radius: 50%; 251 | -moz-border-radius: 50%; 252 | -webkit-border-radius: 50%; 253 | color: #555; 254 | display: block; 255 | font-size: 1.7rem; 256 | font-weight: 600; 257 | height: 3.2rem; 258 | line-height: 1.7em; 259 | margin: 0 auto 1rem auto; 260 | text-align: center; 261 | width: 3.2rem; 262 | } 263 | 264 | img { 265 | display: block; 266 | height: auto; 267 | margin: 0 auto 1.5rem auto; 268 | width: 100%; 269 | } 270 | 271 | .rwd { 272 | margin: 0 auto 1.5rem auto; 273 | max-width: 440px; 274 | } 275 | 276 | /* Examples 277 | ========================================================================== */ 278 | 279 | .example { 280 | border-top: none; 281 | background-color: #497bad; 282 | color: #fff; 283 | } 284 | 285 | .example p { color: rgba(255,255,255,0.7); } 286 | .example img { margin: 0; } 287 | 288 | .fragmentation { 289 | background-image: url("../images/fragmentation.png"); 290 | background-size: cover; 291 | min-height: 250px; 292 | } 293 | 294 | @media (min-width: 40rem) { 295 | .fragmentation { min-height: 500px; } 296 | } 297 | 298 | .mobile-first .column { 299 | float: none; 300 | margin-bottom: 1rem; 301 | } 302 | 303 | .grid { text-align: center; } 304 | 305 | .grid span { 306 | background: rgba(225,255,255,0.1); 307 | border: 2px solid rgba(255,255,255,0.2); 308 | display: block; 309 | padding: 1rem; 310 | font-size: 0.9rem; 311 | font-weight: 600; 312 | } 313 | 314 | .grid .container { 315 | border: 2px dashed rgba(255,255,255,0.3); 316 | padding: 1rem 1rem 0 1rem; 317 | } 318 | 319 | @media (min-width: 40rem) { 320 | .grid .container { padding: 1rem 0 0 0; } 321 | } 322 | 323 | .grid .column { margin-bottom: 1rem; } 324 | 325 | .row-example .container { 326 | border: 2px dashed rgba(255,255,255,0.2); 327 | padding: 1rem; 328 | } 329 | 330 | .row-example .row { 331 | background: rgba(225,255,255,0.1); 332 | border: 2px solid rgba(255,255,255,0.2); 333 | padding: 1rem 1rem 0 1rem; 334 | margin-bottom: 1rem; 335 | } 336 | 337 | .row-example .row:last-of-type { margin-bottom: 0; } 338 | 339 | @media (min-width: 40rem) { 340 | .row-example .row { padding: 1rem 0 0 0; } 341 | } 342 | 343 | .gutters { 344 | border: 2px dashed #eee; 345 | margin-bottom: 2rem; 346 | max-width: 39rem; 347 | padding: 1rem 1rem 0 1rem; 348 | } 349 | 350 | .gutters .column { 351 | background: #fb917e; 352 | margin-bottom: 1rem; 353 | } 354 | 355 | .gutters span { 356 | background: #f8f8f8; 357 | color: #999; 358 | display: block; 359 | padding: 1rem 0; 360 | } 361 | 362 | /* Box Model 363 | ========================================================================== */ 364 | 365 | .box-model h1 { margin-bottom: 3rem; } 366 | 367 | .margin { color: #f9cd9d; } 368 | .border { color: #fce08f; } 369 | .padding { color: #c2ddb6; } 370 | .content { color: #9ec3e5; } 371 | 372 | /* Gist Overrides 373 | ========================================================================== */ 374 | 375 | .gist .gist-file { 376 | font-size: .9rem !important; 377 | margin: 0 auto; 378 | max-width: 39rem; 379 | overflow: hidden !important; 380 | text-align: left; 381 | } 382 | 383 | .gist .gist-file .gist-data { 384 | background: #f8f8f8 !important; 385 | border-bottom: none !important; 386 | } 387 | 388 | .gist .gist-file .gist-meta { 389 | display: none !important; 390 | } 391 | 392 | .gist-syntax .k { 393 | color: #555 !important; 394 | font-weight: normal !important; 395 | } 396 | 397 | /* Animate.css by Daniel Eden 398 | ========================================================================== */ 399 | 400 | .animated{-webkit-animation-fill-mode:both;-moz-animation-fill-mode:both;-ms-animation-fill-mode:both;-o-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:2s;-moz-animation-duration:2s;-ms-animation-duration:2s;-o-animation-duration:2s;animation-duration:2s;}.animated.hinge{-webkit-animation-duration:2s;-moz-animation-duration:2s;-ms-animation-duration:2s;-o-animation-duration:2s;animation-duration:2s;}@-webkit-keyframes fadeInUp { 401 | 0% { 402 | opacity: 0; 403 | -webkit-transform: translateY(20px); 404 | } 100% { 405 | opacity: 1; 406 | -webkit-transform: translateY(0); 407 | } 408 | } 409 | 410 | @-moz-keyframes fadeInUp { 411 | 0% { 412 | opacity: 0; 413 | -moz-transform: translateY(20px); 414 | } 415 | 416 | 100% { 417 | opacity: 1; 418 | -moz-transform: translateY(0); 419 | } 420 | } 421 | 422 | @-o-keyframes fadeInUp { 423 | 0% { 424 | opacity: 0; 425 | -o-transform: translateY(20px); 426 | } 427 | 428 | 100% { 429 | opacity: 1; 430 | -o-transform: translateY(0); 431 | } 432 | } 433 | 434 | @keyframes fadeInUp { 435 | 0% { 436 | opacity: 0; 437 | transform: translateY(20px); 438 | } 439 | 440 | 100% { 441 | opacity: 1; 442 | transform: translateY(0); 443 | } 444 | } 445 | 446 | .fadeInUp { 447 | -webkit-animation-name: fadeInUp; 448 | -moz-animation-name: fadeInUp; 449 | -o-animation-name: fadeInUp; 450 | animation-name: fadeInUp; 451 | } 452 | 453 | /* Utilities 454 | ========================================================================== */ 455 | 456 | .remove-padding { padding-bottom: 0; } 457 | .remove-border { border: none; } 458 | 459 | /* Clearfix by Nicolas Gallagher 460 | ========================================================================== */ 461 | 462 | .clearfix:before, 463 | .clearfix:after { 464 | content: " "; 465 | display: table; 466 | } 467 | 468 | .clearfix:after { clear: both; } 469 | .clearfix { *zoom: 1; } 470 | -------------------------------------------------------------------------------- /css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.0 | MIT License | git.io/normalize */ 2 | 3 | /** 4 | * 1. Set default font family to sans-serif. 5 | * 2. Prevent iOS text size adjust after orientation change, without disabling 6 | * user zoom. 7 | */ 8 | 9 | html { 10 | font-family: sans-serif; /* 1 */ 11 | -ms-text-size-adjust: 100%; /* 2 */ 12 | -webkit-text-size-adjust: 100%; /* 2 */ 13 | } 14 | 15 | /** 16 | * Remove default margin. 17 | */ 18 | 19 | body { 20 | margin: 0; 21 | } 22 | 23 | /* HTML5 display definitions 24 | ========================================================================== */ 25 | 26 | /** 27 | * Correct `block` display not defined in IE 8/9. 28 | */ 29 | 30 | article, 31 | aside, 32 | details, 33 | figcaption, 34 | figure, 35 | footer, 36 | header, 37 | hgroup, 38 | main, 39 | nav, 40 | section, 41 | summary { 42 | display: block; 43 | } 44 | 45 | /** 46 | * 1. Correct `inline-block` display not defined in IE 8/9. 47 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. 48 | */ 49 | 50 | audio, 51 | canvas, 52 | progress, 53 | video { 54 | display: inline-block; /* 1 */ 55 | vertical-align: baseline; /* 2 */ 56 | } 57 | 58 | /** 59 | * Prevent modern browsers from displaying `audio` without controls. 60 | * Remove excess height in iOS 5 devices. 61 | */ 62 | 63 | audio:not([controls]) { 64 | display: none; 65 | height: 0; 66 | } 67 | 68 | /** 69 | * Address `[hidden]` styling not present in IE 8/9. 70 | * Hide the `template` element in IE, Safari, and Firefox < 22. 71 | */ 72 | 73 | [hidden], 74 | template { 75 | display: none; 76 | } 77 | 78 | /* Links 79 | ========================================================================== */ 80 | 81 | /** 82 | * Remove the gray background color from active links in IE 10. 83 | */ 84 | 85 | a { 86 | background: transparent; 87 | } 88 | 89 | /** 90 | * Improve readability when focused and also mouse hovered in all browsers. 91 | */ 92 | 93 | a:active, 94 | a:hover { 95 | outline: 0; 96 | } 97 | 98 | /* Text-level semantics 99 | ========================================================================== */ 100 | 101 | /** 102 | * Address styling not present in IE 8/9, Safari 5, and Chrome. 103 | */ 104 | 105 | abbr[title] { 106 | border-bottom: 1px dotted; 107 | } 108 | 109 | /** 110 | * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. 111 | */ 112 | 113 | b, 114 | strong { 115 | font-weight: bold; 116 | } 117 | 118 | /** 119 | * Address styling not present in Safari 5 and Chrome. 120 | */ 121 | 122 | dfn { 123 | font-style: italic; 124 | } 125 | 126 | /** 127 | * Address variable `h1` font-size and margin within `section` and `article` 128 | * contexts in Firefox 4+, Safari 5, and Chrome. 129 | */ 130 | 131 | h1 { 132 | font-size: 2em; 133 | margin: 0.67em 0; 134 | } 135 | 136 | /** 137 | * Address styling not present in IE 8/9. 138 | */ 139 | 140 | mark { 141 | background: #ff0; 142 | color: #000; 143 | } 144 | 145 | /** 146 | * Address inconsistent and variable font size in all browsers. 147 | */ 148 | 149 | small { 150 | font-size: 80%; 151 | } 152 | 153 | /** 154 | * Prevent `sub` and `sup` affecting `line-height` in all browsers. 155 | */ 156 | 157 | sub, 158 | sup { 159 | font-size: 75%; 160 | line-height: 0; 161 | position: relative; 162 | vertical-align: baseline; 163 | } 164 | 165 | sup { 166 | top: -0.5em; 167 | } 168 | 169 | sub { 170 | bottom: -0.25em; 171 | } 172 | 173 | /* Embedded content 174 | ========================================================================== */ 175 | 176 | /** 177 | * Remove border when inside `a` element in IE 8/9. 178 | */ 179 | 180 | img { 181 | border: 0; 182 | } 183 | 184 | /** 185 | * Correct overflow displayed oddly in IE 9. 186 | */ 187 | 188 | svg:not(:root) { 189 | overflow: hidden; 190 | } 191 | 192 | /* Grouping content 193 | ========================================================================== */ 194 | 195 | /** 196 | * Address margin not present in IE 8/9 and Safari 5. 197 | */ 198 | 199 | figure { 200 | margin: 1em 40px; 201 | } 202 | 203 | /** 204 | * Address differences between Firefox and other browsers. 205 | */ 206 | 207 | hr { 208 | -moz-box-sizing: content-box; 209 | box-sizing: content-box; 210 | height: 0; 211 | } 212 | 213 | /** 214 | * Contain overflow in all browsers. 215 | */ 216 | 217 | pre { 218 | overflow: auto; 219 | } 220 | 221 | /** 222 | * Address odd `em`-unit font size rendering in all browsers. 223 | */ 224 | 225 | code, 226 | kbd, 227 | pre, 228 | samp { 229 | font-family: monospace, monospace; 230 | font-size: 1em; 231 | } 232 | 233 | /* Forms 234 | ========================================================================== */ 235 | 236 | /** 237 | * Known limitation: by default, Chrome and Safari on OS X allow very limited 238 | * styling of `select`, unless a `border` property is set. 239 | */ 240 | 241 | /** 242 | * 1. Correct color not being inherited. 243 | * Known issue: affects color of disabled elements. 244 | * 2. Correct font properties not being inherited. 245 | * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. 246 | */ 247 | 248 | button, 249 | input, 250 | optgroup, 251 | select, 252 | textarea { 253 | color: inherit; /* 1 */ 254 | font: inherit; /* 2 */ 255 | margin: 0; /* 3 */ 256 | } 257 | 258 | /** 259 | * Address `overflow` set to `hidden` in IE 8/9/10. 260 | */ 261 | 262 | button { 263 | overflow: visible; 264 | } 265 | 266 | /** 267 | * Address inconsistent `text-transform` inheritance for `button` and `select`. 268 | * All other form control elements do not inherit `text-transform` values. 269 | * Correct `button` style inheritance in Firefox, IE 8+, and Opera 270 | * Correct `select` style inheritance in Firefox. 271 | */ 272 | 273 | button, 274 | select { 275 | text-transform: none; 276 | } 277 | 278 | /** 279 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` 280 | * and `video` controls. 281 | * 2. Correct inability to style clickable `input` types in iOS. 282 | * 3. Improve usability and consistency of cursor style between image-type 283 | * `input` and others. 284 | */ 285 | 286 | button, 287 | html input[type="button"], /* 1 */ 288 | input[type="reset"], 289 | input[type="submit"] { 290 | -webkit-appearance: button; /* 2 */ 291 | cursor: pointer; /* 3 */ 292 | } 293 | 294 | /** 295 | * Re-set default cursor for disabled elements. 296 | */ 297 | 298 | button[disabled], 299 | html input[disabled] { 300 | cursor: default; 301 | } 302 | 303 | /** 304 | * Remove inner padding and border in Firefox 4+. 305 | */ 306 | 307 | button::-moz-focus-inner, 308 | input::-moz-focus-inner { 309 | border: 0; 310 | padding: 0; 311 | } 312 | 313 | /** 314 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in 315 | * the UA stylesheet. 316 | */ 317 | 318 | input { 319 | line-height: normal; 320 | } 321 | 322 | /** 323 | * It's recommended that you don't attempt to style these elements. 324 | * Firefox's implementation doesn't respect box-sizing, padding, or width. 325 | * 326 | * 1. Address box sizing set to `content-box` in IE 8/9/10. 327 | * 2. Remove excess padding in IE 8/9/10. 328 | */ 329 | 330 | input[type="checkbox"], 331 | input[type="radio"] { 332 | box-sizing: border-box; /* 1 */ 333 | padding: 0; /* 2 */ 334 | } 335 | 336 | /** 337 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain 338 | * `font-size` values of the `input`, it causes the cursor style of the 339 | * decrement button to change from `default` to `text`. 340 | */ 341 | 342 | input[type="number"]::-webkit-inner-spin-button, 343 | input[type="number"]::-webkit-outer-spin-button { 344 | height: auto; 345 | } 346 | 347 | /** 348 | * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. 349 | * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome 350 | * (include `-moz` to future-proof). 351 | */ 352 | 353 | input[type="search"] { 354 | -webkit-appearance: textfield; /* 1 */ 355 | -moz-box-sizing: content-box; 356 | -webkit-box-sizing: content-box; /* 2 */ 357 | box-sizing: content-box; 358 | } 359 | 360 | /** 361 | * Remove inner padding and search cancel button in Safari and Chrome on OS X. 362 | * Safari (but not Chrome) clips the cancel button when the search input has 363 | * padding (and `textfield` appearance). 364 | */ 365 | 366 | input[type="search"]::-webkit-search-cancel-button, 367 | input[type="search"]::-webkit-search-decoration { 368 | -webkit-appearance: none; 369 | } 370 | 371 | /** 372 | * Define consistent border, margin, and padding. 373 | */ 374 | 375 | fieldset { 376 | border: 1px solid #c0c0c0; 377 | margin: 0 2px; 378 | padding: 0.35em 0.625em 0.75em; 379 | } 380 | 381 | /** 382 | * 1. Correct `color` not being inherited in IE 8/9. 383 | * 2. Remove padding so people aren't caught out if they zero out fieldsets. 384 | */ 385 | 386 | legend { 387 | border: 0; /* 1 */ 388 | padding: 0; /* 2 */ 389 | } 390 | 391 | /** 392 | * Remove default vertical scrollbar in IE 8/9. 393 | */ 394 | 395 | textarea { 396 | overflow: auto; 397 | } 398 | 399 | /** 400 | * Don't inherit the `font-weight` (applied by a rule above). 401 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. 402 | */ 403 | 404 | optgroup { 405 | font-weight: bold; 406 | } 407 | 408 | /* Tables 409 | ========================================================================== */ 410 | 411 | /** 412 | * Remove most spacing between table cells. 413 | */ 414 | 415 | table { 416 | border-collapse: collapse; 417 | border-spacing: 0; 418 | } 419 | 420 | td, 421 | th { 422 | padding: 0; 423 | } -------------------------------------------------------------------------------- /images/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/border.png -------------------------------------------------------------------------------- /images/box-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/box-model.png -------------------------------------------------------------------------------- /images/container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/container.png -------------------------------------------------------------------------------- /images/content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/content.png -------------------------------------------------------------------------------- /images/desktop-first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/desktop-first.png -------------------------------------------------------------------------------- /images/fragmentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/fragmentation.png -------------------------------------------------------------------------------- /images/margin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/margin.png -------------------------------------------------------------------------------- /images/mobile-first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/mobile-first.png -------------------------------------------------------------------------------- /images/mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/mobile.png -------------------------------------------------------------------------------- /images/padding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/padding.png -------------------------------------------------------------------------------- /images/small-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/small-large.png -------------------------------------------------------------------------------- /images/with-box-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/with-box-model.png -------------------------------------------------------------------------------- /images/without-box-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webfatorial/grid/f61ff1fbd8872ad5db22973e0260eee9995e8f7b/images/without-box-model.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Grid 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 |
27 |
28 |

grid

29 |

Um guia simples para design responsivo. 30 |
Feito por Adam Kaplan. Versão brasileira por webfatorial.

31 |
32 | Intro 33 |
34 |
35 | 36 |
37 |
38 | Mobile First 39 |

Por que se importar com responsivo?

40 |

Queremos que nossos sites sejam usáveis em todos os dispositivos, respondendo ao comportamento e tamanho e orientação de tela do visitante.

41 |
42 |
43 | 44 |
45 |
46 |
47 | 48 |
49 |
50 |

Um mundo fragmentado

51 |

Desde 2013 existem milhares de diferentes dispositivos e tamanhos de tela que acessam a internet, tornando impossível projetar layouts para todos. Ao invés disso, precisamos adotar uma abordagem mais fluida ao design.

52 |
53 |
54 | 55 |
56 |
57 |

Mobile First

58 |

O termo "mobile first" (móvel primeiro) tem aparecido bastante ultimamente. O que isso realmente significa é começar com os estilos para mobile e ir avançando em estilos otimizados para telas maiores apenas quando necessário. Em outras palavras, seus estilos para dispositivos móveis se tornam o padrão e você não os precisa mais sobrescrever depois. é muito mais simples!

59 |
60 |
61 |

Assumindo um layout flexível, mas simples, por padrão, você pode melhor se resguardar contra navegadores — com viewports pequenas e grandes — que não são totalmente capazes em relação a layout responsivo. Então, quando falamos sobre layout, "mobile first" realmente significa "progressive enhancement" (melhoramento progressivo).

62 | —Ethan Marcotte 63 |
64 |
65 |
66 | 67 |
68 |
69 | Mobile First 70 |
71 |
72 | 73 |
74 |
75 |

Media queries com min-width

76 |

Introduza regras específicas ao layout somente quando precisar delas. Use min-width para lidar com complexidade à medida em que a viewport se torna maior. É mais fácil ter todas as media queries próximas ao invés de no final da folha de estilos ou em documento separado.

77 |
78 | 79 |
80 |
81 | 82 |
83 |
84 |
1
85 |

Nem todos os navegadores são iguais

86 |

Navegadores irão renderizar seu CSS de maneira diferente. Para evitar isso, é uma boa ideia usar uma alternativa moderna ao reset, como Normalize.css, que irá renderizar seus elementos mais consistentemente entre os navegadores (cross-browser). Lembre-se de incluí-lo antes de sua folha de estilos.

87 |
88 | 89 |
90 |
91 | 92 |
93 |
94 |
2
95 |

Adicione a meta tag Viewport

96 |

Coloque na <head> de seu HTML. Isso habilita o uso de media queries para layouts cross-device.

97 |
98 | 99 |
100 |
101 | 102 |
103 |
104 | Box Model 105 |
106 |
107 | 108 |
109 |
110 |

CSS Box Model

111 |

É importante entender o básico, tal como os elementos são gerados e se comportam no navegador, antes de se aprofundar em web design responsivo. O CSS Box Model consiste em quatro partes diferentes.

112 |
113 |
114 |
115 | content 116 |

Conteúdo

117 |

O conteúdo do box, onde texto e imagem aparecem.

118 |
119 | 120 |
121 | padding 122 |

Padding

123 |

Área ao redor do conteúdo.

124 |
125 | 126 |
127 | border 128 |

Border

129 |

Borda que vai ao redor do padding.

130 |
131 | 132 |
133 | margin 134 |

Margin

135 |

Área ao redor da borda.

136 |
137 |
138 |
139 |
140 | 141 |
142 |
143 |
3
144 |

Use box-sizing: border-box

145 |

Coloque no início de seu arquivo CSS. O * vai afetar todos os elementos na página.

146 |
147 | 148 |
149 |
150 | 151 |
152 |
153 |

Sua Escolha

154 |

O que antes era um bug 155 | é agora uma propriedade CSS amplamente usada. Basicamente, isso significa que você pode escolher entre incluir ou não border e padding no cálculo da largura de seu conteúdo.

156 |
157 | 158 |
159 |
160 | Without Box Model 161 |

Sem box-sizing: border-box

162 |

Margem, bordas e padding são desenhados fora da especificação de largura do conteúdo.

163 |
164 | 165 |
166 | With Box Model 167 |

Com box-sizing: border-box

168 |

Bordas e padding são desenhados dentro da especificação da largura do conteúdo. A margem é desenhada fora.

169 |
170 |
171 |
172 |
173 | 174 |
175 |
176 |
4
177 |

Crie um contêiner

178 |

Um contêiner detém todos os elementos e controla a largura máxima da página. Usando um contêiner você faz de projetos de design responsivo mais fáceis!

179 |
180 | 181 | 182 |
183 |
184 | 185 |
186 |
187 | Container 188 |
189 |
190 | 191 |
192 |
193 |
5
194 |

Crie uma coluna

195 |

Com mobile first, colunas são nível de bloco (block), por padrão tomando a largura total disponível. Nenhum estilo adicional é necessário!

196 |
197 | 198 |
199 |
200 | 201 |
202 |
203 |
204 | .column 205 |
206 | 207 |
208 | .column 209 |
210 | 211 |
212 | .column 213 |
214 | 215 |
216 | .column 217 |
218 |
219 |
220 | 221 |
222 |
223 |
6
224 |

Crie tamanhos de colunas

225 |

Em telas grandes, colunas obtêm float: left a fim de "empilhar" (stack) o conteúdo horizontalmente. Colunas agora usam padding para espaçamento, então você não precisa mais se preocupar em remover margens.

226 |
227 |
228 | 229 |
230 |
231 |
232 | .column .half 233 |
234 | 235 |
236 | .column .half 237 |
238 |
239 |
240 | 241 |
242 | 243 | 244 |
245 |
246 | 247 |
248 |
249 |
250 |
251 | .column .full 252 |
253 |
254 | 255 |
256 |
257 | .column .two-thirds 258 |
259 | 260 |
261 | .column .third 262 |
263 |
264 | 265 |
266 |
267 | .column .half 268 |
269 | 270 |
271 | .column .half 272 |
273 |
274 | 275 |
276 |
277 | .column .third 278 |
279 | 280 |
281 | .column .third 282 |
283 | 284 |
285 | .column .third 286 |
287 |
288 | 289 |
290 |
291 | .column .fourth 292 |
293 | 294 |
295 | .column .fourth 296 |
297 | 298 |
299 | .column .fourth 300 |
301 | 302 |
303 | .column .fourth 304 |
305 |
306 |
307 |
308 | 309 |
310 |
311 |
7
312 |

Crie linhas

313 |

Colunas são envoltas em linhas para evitar que outros elementos fiquem "empilhados" (stacking) próximo a elas, isso também conhecido como "questões de limpeza" (clearing issues). Linhas recebem clear usando o popular clearfix, criado por Nicolas Gallagher.

314 |
315 | 316 | 317 |
318 |
319 | 320 |
321 |
322 |
323 |
324 | .column .half 325 |
326 | 327 |
328 | .column .half 329 |
330 |
331 | 332 |
333 |
334 | .column .half 335 |
336 | 337 |
338 | .column .half 339 |
340 |
341 |
342 |
343 | 344 |
345 |
346 |

Fluxo Oposto

347 |

Adicione a classe .flow-opposite em colunas nas quais você quer o conteúdo apareça primeiro em mobile, mas apareçam à direita em telas maiores.

348 |
349 | 350 | 351 |
352 |
353 | 354 |
355 |
356 |
357 |
358 | .column .half .flow-opposite 359 |
360 | 361 |
362 | .column .half 363 |
364 |
365 |
366 |
367 | 368 |
369 |
370 |

A prática leva à perfeição

371 |

Seguindo esses simples passos, você está no caminho para dominar o web design responsivo. Continue a praticar e ajude a tornar a web um lugar melhor e mais usável.

372 |
373 |

Veja o código

374 |
375 |
376 | 377 |
378 |
379 | 408 |
409 |
410 | 411 | 412 | --------------------------------------------------------------------------------