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

An introduction to CSS3 for web developers

Rachel Andrew
November 29, 2011

An introduction to CSS3 for web developers

Presentation for Microsoft TechDays, May 2011

Rachel Andrew

November 29, 2011
Tweet

More Decks by Rachel Andrew

Other Decks in Technology

Transcript

  1. W3C MATURITY LEVELS •Working Draft •Candidate Recommendation •Proposed Recommendation •W3C

    Recommendation http://www.w3.org/2005/10/Process-20051014/tr#maturity-levels
  2. IN DEFENCE OF VENDOR-SPECIFIC EXTENSIONS •W3C Approved way to add

    extensions •If a module changes browser doesn’t need to change and break older code
  3. IN DEFENCE OF VENDOR-SPECIFIC EXTENSIONS •W3C Approved way to add

    extensions •If a module changes browser doesn’t need to change and break older code •Use with care - and always include the real property
  4. THE PROBLEM WITH CSS2 SELECTORS Not precise Led to “classitis”

    If we can’t access mark-up it is hard to target things
  5. label[for="fContact"] { ! float: none; ! width: auto; } a[href

    ^="mailto:"] { ! ! padding-right: 20px; ! ! background-image:url(email.png); ! ! background-repeat: no-repeat; ! ! background-position: right center; } Attribute Selectors
  6. div#wrapper p:first-child, div#wrapper p.first { ! ! font-size: 1.5em; }

    jQuery: first-child <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ ! $("div#wrapper p:first-child").addClass("first"); }); </script>
  7. ul#navigation li:last-child, ul#navigation li.last { ! ! border-bottom: none; }

    jQuery: last-child <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ ! $("ul#navigation li:last-child").addClass("last"); }); </script>
  8. tr:nth-child(odd) td, td.odd { ! background-color: #f0e9c5; } jQuery: nth-child

    <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ ! $("tr:nth-child(odd) td").addClass("odd"); }); </script>
  9. USE A “POLYFILL” “A polyfill, or polyfiller, is a piece

    of code (or plugin) that provides the technology that you, the developer, expect the browser to provide natively. Flattening the API landscape if you will.” Remy Sharp - http://remysharp.com/2010/10/08/what-is-a-polyfill/
  10. @font-face { ! font-family: KaffeesatzBold; ! src: url(YanoneKaffeesatz-Bold.ttf); } h1

    { ! font-family: KaffeesatzBold, sans-serif; ! font-weight: normal; } @font-face
  11. BROWSER COMPATIBILITY We need to use different types of fonts

    for different browsers and operating systems
  12. @font-face { ! font-family: 'YanoneKaffeesatzBold'; ! ! src: url('yanonekaffeesatz-bold-webfont.eot'); !

    ! src: local('☺'), url('yanonekaffeesatz-bold-webfont.woff') format('woff'), url('yanonekaffeesatz-bold-webfont.ttf') format('truetype'), url('yanonekaffeesatz-bold-webfont.svg#webfontUcEp3Pt5') format('svg'); ! font-weight: normal; ! font-style: normal; } FONT SQUIRREL
  13. blockquote { ! ! background: url(quote-left.gif) top left no-repeat, !

    ! url(quote-right.gif) bottom right no- repeat; ! } backgrounds
  14. .box1 { ! ! background-color: #a18c83; ! ! border: 3px

    solid #6d4d6b; ! ! -moz-border-radius: 15px; ! ! -webkit-border-radius: 15px; border-radius: 15px; ! ! color: #fff; ! ! padding: 10px; ! ! margin: 0 0 20px 0; ! } ! ! .box2 { ! ! border: 5px solid #6d4d6b; ! ! -moz-border-radius-topleft: 50px; ! ! -webkit-border-top-left-radius: 50px; border-top-left-radius: 50px; ! ! padding: 10px 5px 5px 20px; ! } border-radius
  15. .box1 { ! ! background-color: #333; ! ! -moz-border-radius: 15px;

    ! ! -webkit-border-radius: 15px; border-radius: 15px; -moz-box-shadow: 10px 10px 5px #666; -webkit-box-shadow: 10px 10px 5px #666; box-shadow: 10px 10px 5px #666; ! ! color: #fff; ! ! padding: 10px; ! ! margin: 0 0 20px 0; ! } box-shadow
  16. div#wrapper { ! width: 780px; ! margin-left: auto; ! margin-right:

    auto; } ! div#header { ! background-image: url(media-queries-browser.jpg); ! height: 349px; ! position: relative; } ! #content { ! float: left; ! width: 540px; } ! #navigation { ! float:right; ! width: 200px; } Media Queries
  17. @media screen and (max-device-width: 480px) { ! ! div#wrapper {

    ! ! ! width: 400px; ! ! } ! ! ! div#header { ! ! ! background-image: url(media-queries-phone.jpg); ! ! ! height: 93px; ! ! ! position: relative; ! ! } ! ! ! ! div#header h1 { ! ! ! font-size: 140%; ! ! } ! ! ! ! #content { ! ! ! float: none; ! ! ! width: 100%; ! ! } ! ! ! #navigation { ! ! ! float:none; ! ! ! width: auto; ! ! } ! } Media Queries
  18. THANK YOU! @rachelandrew http://wp.me/PorPc-cf Photo credit for Media Queries example:

    http://www.flickr.com/photos/dominicspics/4625808875/ Font for web fonts example: http://www.yanone.de/typedesign/kaffeesatz/