Mastering CSS Layouts

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    29 Favorites

    Mastering CSS Layouts - Presentation Transcript

    1. Mastering C S S Layouts D E LV E : U I C S S M A S T E RC L A S S W E D N E S D AY , A U G U S T 5, 2009 by J I N A B O LT O N INTERACTION DESIGNER CRUSH + L O V E LY
    2. Buongiorno! M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    3. Mastering C S S Layouts Once & for All? M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    4. Becoming a “master” of C S S is more than just memorizing selectors. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    5. It’s about mastering your workflow. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    6. Create efficient, maintainable, & smart (sexy) C S S . M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    7. A Consistent Workflow M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    8. Create a development starter toolkit. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    9. An organized directory structure for all projects. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    10. images/ content/ layout/ javascripts/ stylesheets/ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    11. img/ js/ css/ i/ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    12. Barebones H T M L template M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    13. A Simple, Usable, & Clean C S S Framework M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    14. @import 'reset.css'; @import 'foundation.css'; M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    15. Optional: Your Chosen JavaScript Framework M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    16. Design from the content out or from outside in? M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    17. Begin with meaningful markup. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    18. Write it clean; keep it clean. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    19. Clarity is beautiful. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    20. <div id="product_description">...</div> vs. <div id="leftl07">...</div> M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    21. Organization M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    22. Keep your selectors & declarations organized. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    23. Sele%ors Element Types DOM Hierarchy Style Types M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    24. Declarations Alphabetical Style Types M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    25. Comments are your friend. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    26. /* Company Name Typography CSS Author Jina Bolton Version v1.0 | 2008-09-25 ........................................................................ */ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    27. /* Background 222 Text fff Links c99 Visited Links 966 Hovered Links fcc Headers 9cc Sub-headers 699 ........................................................................ */ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    28. /* =RESET ........................................................................ */ /* =TYPOGRAPHY ........................................................................ */ /* =STRUCTURE ........................................................................ */ See: http://stopdesign.com/log/2005/05/03/css-tip- ags.html M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    29. /* RESET GLOBAL TYPOGRAPHY STRUCTURE FORMS TABLES WIDGETS ........................................................................ */ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    30. profile.css #pro le { width: 600px; /* rede ned: IE-6.css */ } IE-6.css #pro le { width: 620px; /* override: pro le.css */ } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    31. Balance readability & optimization. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    32. Debugging M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    33. Validate your code. W3C HTML Validator http://validator.w3.org/ CSS Validator http://jigsaw.w3.org/css-validator/ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    34. Use C S S 3 to display problem areas. *[style] { border: 2px dashed red !important; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    35. Documentation M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    36. At least try to document your work! M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    37. Techniques M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    38. The Box Model M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    39. Image by Andy Clarke, adapted from the original image created by Jon Hicks http://www.hicksdesign.co.uk/boxmodel/ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    40. Normal Flow Elements flow naturally on the page, in the order that they appear in the source. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    41. Floats M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    42. Floats were not intended for layout. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    43. Avoid using floats as a fallback bug fix. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    44. Positioning M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    45. Relative Positioning Moves the element by coordinates relative to where it lives within “normal flow”. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    46. Absolute Positioning Removes the element from normal flow and positions by coordinates to the nearest parent element that has relative positioning. By default, the element will position to the viewport if no parent exists that has relative positioning. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    47. Fixed Positioning Removes the element from normal flow and positions by coordinates to the viewport. This element does not scroll with the rest of the page. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    48. Static Positioning Reverts positioning to normal flow. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    49. Rounded Corners M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    50. CSS 3 The best-case scenario. .entry-content { border: 1px solid #ccc; -moz-border-radius: 10px; -webkit-border-radius: 10px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    51. CSS + Images Techniques Consider which of the several techniques fits best. Do$ your d$ign have a fixed width? Wi% that always be the c&e? How about the height? Could th' change & the co(e( grows shorter/longer? M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    52. Fixed width, varied height (short version) A full-width, tall image for the top, left, and right borders. A full-width, short image for the bottom border. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    53. Fixed width, varied height (short version) .module { background: url(demo-tlr.gif ) no-repeat; } .module .content { padding-bottom: 10px; background: url(demo-btm.gif ) bottom no-repeat; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    54. Fixed width, varied height (long version) A full-width, short image for the top border. A full-width, short repeating image for the left and right borders. A full-width, short image for the bottom border. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    55. Fixed width, varied height (long version) .module { padding-top: 10px; background: url(demo-tlr.gif ) no-repeat; } .module .content { padding-bottom: 10px; background: url(demo-btm.gif ) left bottom no-repeat; } .module .content-wrap { background: url(demo-lr.gif ) repeat-y; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    56. Varied width, varied height A very wide, very tall image for the top and left borders. A skinny, very tall image for the top right corner and right border. A very wide, short image for the bottom right corner and bottom border. A skinny, short image for the bottom left corner. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    57. Varied width, varied height .module { background: url(demo-tl.gif ) no-repeat; } .module-3 .content { background: url(demo-tr.gif ) right top no-repeat; } .module-3 .content-wrap { background: url(demo-br.gif ) right bottom no-repeat; } .module-3 .content-wrap-2 { padding-top: 10px; padding-bottom: 10px; background: url(demo-bl.gif ) left bottom no-repeat; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    58. CSS Sprites M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    59. A.K.A. “Navigation Matrix” M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    60. <ul id="menu"> <li id="m-home"><a href="#">Home</a></li> <li id="m-about"><a href="#">About</a></li> <li id="m-news"><a href="#">News</a></li> <li id="m-events"><a href="#">Events</a></li> <li id="m-links"><a href="#">Links</a></li> <li id="m-contacts"><a href="#">Contacts</a></li> </ul> M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    61. ul#menu { list-style: none; } ul#menu li { display: inline; } ul#menu a { oat: left width: 100px; height: 50px; text-indent: -9999em; background: url(menu.gif ); } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    62. ul#menu li#m-home a { background-position: 0 0; } ul#menu li#m-about a { background-position: -100px 0; } ul#menu li#m-news a { background-position: -200px 0; } ul#menu li#m-events a { background-position: -300px 0; } ul#menu li#m-links a { background-position: -400px 0; } ul#menu li#m-contacts a { background-position: -500px 0; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    63. ul#menu li#m-home a:hover { background-position: 0 -50px; } ul#menu li#m-about a:hover { background-position: -100px -50px; } ul#menu li#m-news a:hover { background-position: -200px -50px; } ul#menu li#m-events a:hover { background-position: -300px -50px; } ul#menu li#m-links a:hover { background-position: -400px -50px; } ul#menu li#m-contacts a:hover { background-position: -500px -50px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    64. ul#menu li#m-home.active a{ background-position: 0 -100px; } ul#menu li#m-about.active a { background-position: -100px -100px; } ul#menu li#m-news.active a { background-position: -200px -100px; } ul#menu li#m-events.active a { background-position: -300px -100px; } ul#menu li#m-links.active a { background-position: -400px -100px; } ul#menu li#m-contacts.active a { background-position: -500px -100px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    65. Negative Margins M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    66. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    67. Conditional comments vs. hacks M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    68. Avoid hacks if possible. Work With the Box Model (not against). Browsers Change. If hacks are absolutely necessary, it can be helpful to explain what was done in your C S S comments. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    69. Master your text editor. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    70. Use version control. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    71. http://dowebsitesneedtolookexactlythesameineverybrowser.com/ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    72. CSS 3 M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    73. “C S S 3: A giant serving of FAIL.” — Alex Russell M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    74. “C S S 3: Third time lucky” — Andy Clarke M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    75. CSS 1 1996 M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    76. CSS 2 1997 M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    77. CSS 2.1 Candidate Recommendation M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    78. CSS 3 ? M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    79. CSS 3 Sele%ors Backgrounds & Borders Multi-column Layout Advanced Layout Grid Positioning Media Queries M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    80. Backgrounds & Borders Style any box’s borders and background including attaching multiple background-images to a single element. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    81. Backgrounds & Borders Style any box’s borders and background including attach multiple background-images to a single element. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    82. Backgrounds & Borders <div class="vcard"> <div class="addr-bl"> Style any box’s borders and background including <div class="addr-tr"> attach multiple background-images to … single a element. </div> </div> </div> M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    83. .vcard { background: Backgrounds #000 & Borders url(a-grad.gif) repeat-x; Style any box’s borders and background including } attach multiple background-images to a single .addr-bl { element. background: url(a-bl.gif) 100% 0 no-repeat; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    84. Backgrounds & Borders Style any box’s borders and <div class="vcard">…</div> background including attach multiple background-images to a single element. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    85. .vcard { background-color: #000; Backgrounds background-image: url(a-grad.gif), & Borders url(a-bl.gif), url(a-tr.gif); Style any box’s borders and background including background-repeat: attach multiple background-images to a single repeat-x, element. no-repeat, no-repeat; background-position: 0 0, 100% 0, 0 100%; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    86. Backgrounds & Borders Style any box’s borders and background including attach multiple background-images to a single element. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    87. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    88. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    89. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    90. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    91. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    92. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    93. <div class="vcard">…</div> .vcard { border-image: url("border.png") 30 30 30 30 stretch; border: double green 1em; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    94. Multi-column Layout Making it simpler to create column layouts without additional markup by using column widths, counts, gaps and rules. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    95. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    96. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    97. <div class="entry-content"> <div class="col first"> … </div> <div class="col"> … </div> </div> M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    98. .entry-content .col { float: left; width: 467px; margin-left: 30px; } .entry-content .first { margin-left: 0; } /* .entry-content clear-fix rules */ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    99. <div class="entry-content"> … </div> .entry-content { column-count: 2; column-gap: 30px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    100. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    101. <div class="entry-content"> … </div> .entry-content { column-width: 270px; column-gap: 30px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    102. Grid Positioning Gives the ability to add invisible grid rules to create grid layouts (like in books and newspapers), and uses sizing and new float properties for placing content. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    103. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    104. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    105. <div class="entry-content"> … </div> .entry-content { column-count: 4; column-gap: 30px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    106. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    107. .entry-content { grid-columns: (30px * *)[4]; column-count: 4; column-gap: 30px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    108. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    109. .entry-content { grid-columns: (30px * *)[4]; grid-rows: 9em 33.3% *; column-count: 4; column-gap: 30px; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    110. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    111. <div class="entry-content"> … <img src="sushi.jpg" class="photo" alt="" /> … </div> M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    112. .entry-content img.photo { float: page bottom left; float-offset: 4gr 1gr; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    113. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    114. <div class="entry-content"> <h2>What is Sushi?</h2> … <img src="sushi.jpg" class="photo" alt="" /> </div> M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    115. .entry-content h2 { float: page top left; width: 6gr; height: 1gr; margin-left: -30px; } .entry-content img.photo { float: page bottom left; float-offset: 4gr 1gr; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    116. Advanced Layout Aims to fully separate visual layout order from a document’s content by defining “slots” in a grid in which content can flow or be placed, or that remain empty — all without additional markup. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    117. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    118. a b c d e f g h i j k l M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    119. a a c d e e g g i j k l M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    120. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    121. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    122. @ @ . . e @ @ h . j j @ M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    123. Sele%ors Refined sele%ors to target an element based on an attribute or position in the document flow plus new pseudo-classes and pseudo-elements. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    124. Sele%ors :nth-child(N) :nth-last-child(N) :nth-of-type(N) :nth-last-of-type(N) :last-child :first-of-type :last-of-type :only-child :only-of-type :root :empty :target M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    125. :nth-child(N) matches elements on the basis of their positions within a parent element’s list of child elements (from beginning to end) M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    126. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    127. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    128. <tr class="alt"></tr> <tr></tr> tr.alt td { background: #ecffd9; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    129. <tr></tr> tr:nth-child(odd) td { background: #ecffd9; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    130. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    131. <tr class="high-rank">…</tr> <tr class="high-rank">…</tr> <tr class="high-rank">…</tr> <tr>…</tr> tr.high-rank td { background: #ecffd9; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    132. <tr>…</tr> tr:nth-child(-n+3) td { background: #ecffd9; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    133. :nth-last-child(N) matches elements on the basis of their positions within a parent element’s list of child elements (from end to beginning) M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    134. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    135. <tr>…</tr> <tr class="low-rank">…</tr> <tr class="low-rank">…</tr> <tr class="low-rank">…</tr> tr.low-rank td { opacity: .75; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    136. <tr>…</tr> tr:nth-last-child(-n+2) td { opacity: .75; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    137. :nth-of-type(N) matches elements on the basis of their positions within a parent element’s list of child elements of the same type M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    138. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    139. M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    140. <p class="intro">…</p> <p>…</p> p.intro { background: #fafcf5; font-size: 1.3em; color: #060; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    141. <p>…</p> p:first-of-type { background: #fafcf5; font-size: 1.3em; color: #030; } M A S T E R I N G C S S L AYO U T S J I N A B O LT O N
    142. Questions? J I N A B O LT O N , interaction designer C RU S H + L OV E LY 2 12 .4 3 1. 46 5 2 N E W YO R K + SAN FRANCISCO C RU S H L O V E LY . C O M slides » crushlovely.com/downloads/mcl fo%ow me » twitter.com/jina M A S T E R I N G C S S L AYO U T S J I N A B O LT O N

    + Jina BoltonJina Bolton, 3 months ago

    custom

    2588 views, 29 favs, 1 embeds more stats

    Finally get to the heart of creating functional, cl more

    More info about this document

    CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

    Go to text version

    • Total Views 2588
      • 2580 on SlideShare
      • 8 from embeds
    • Comments 0
    • Favorites 29
    • Downloads 181
    Most viewed embeds
    • 8 views on http://cssdesign.wdfiles.com

    more

    All embeds
    • 8 views on http://cssdesign.wdfiles.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories