Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Level 1 - Week 5

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Level 1 - Week 5

Avatar for Graham Lewis

Graham Lewis

June 23, 2015

More Decks by Graham Lewis

Other Decks in Technology

Transcript

  1. Box model • Content area - where your text is

    • Padding - visible space around text • Border - visible space around padding • Margin - invisible space around border
  2. Think jaffa cake! • Padding - the sponge • Border

    - the smashing orangy bit in the middle! • Margin - the chocolate topping (except it's not invisible !)
  3. Margin p { margin-top: 10px; margin-right: 20px; margin-bottom: 10px; margin-left:

    20px; } Shorthand p { margin: 10px 20px 10px 20px; }
  4. Border p { border-top: 10px; border-right: 20px; border-bottom: 10px; border-left:

    20px; } Shorthand p { border: 10px 20px 10px 20px; }
  5. Even shorter shorthand p { margin: 10px 20px; padding: 10px

    20px; border: 10px; } Rule-of-thumb Use the long form when you are only controlling 1 side - otherwise use the shothand forms
  6. Border options p { border-width: 1px; border-style: solid; border-color: #FFFFFF;

    border-radius: 6px; } Shorthand p { border: 1px solid #FFFFFF; }
  7. How to 'reset' the box model * { padding: 0;

    margin: 0; border: 0; } ! Improves rendering across different browsers, but means you need to add your own padding, margin and border