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

Web Cross Device

Web Cross Device

Presentazione relativa al workshop tenuto alla Wired Next Fest 2015.

Jacopo Rabolini

May 23, 2015
Tweet

More Decks by Jacopo Rabolini

Other Decks in Programming

Transcript

  1. Web Cross Device GDG Milano @ Wired Next Fest 2015

    gdgmilano.org / jacoporabolini.com
  2. 4 approcci differenti Fixed unità di misura assolute Fluid unità

    di misura relative Adaptive layout specifici per device Responsive Fluid + Adaptive
  3. Da Fixed a Fluid: text <h2> Questo è un titolo

    <a href=”#”>e questo un link</a> </h2> HTML
  4. h2 { font-size: 24px; } h2 a { font-size: 18px;

    } h2 { font-size: 1.5em; } /* 24px ÷ 16px */ h2 a { font-size: 0.75em; } /* 18px ÷ 24px */ CSS CSS Da Fixed a Fluid: text
  5. ok ma il context? Per width e margin il context

    è sempre relativo all’elemento contenitore.
  6. .wrap { width: 1024px; } .content { width: 684px; margin-right:

    20px; } .wrap { width: 90%; } /* convertito in % */ .content { width: 66.8%; margin-right: 20px; } CSS CSS Da Fixed a Fluid: width & margin
  7. .wrap { width: 1024px; } .content { width: 684px; margin-right:

    20px; } .wrap { width: 90%; } .content { width: 66.8%; margin-right: 1.95%; } Da Fixed a Fluid: width & margin CSS CSS
  8. .wrap { width: 1024px; } .sidebar { width: 320px; }

    .wrap { width: 90%; } .sidebar { width: 31.25%; } CSS CSS Da Fixed a Fluid: width & margin
  9. .content { width: 684px; margin-right: 20px; } .box { width:

    332px; padding: 10px; } CSS .content { width: 66.8%; margin-right: 1.95%; } .box { width: 48.54%; padding: 3.01%; } CSS Da Fixed a Fluid: padding
  10. Pixel is not a pixel is not a pixel 1)

    Pixel hardware 2) Pixel indipendenti dal dispositivo (dip) 3) Pixel CSS
  11. ok, quali usiamo? ➔ Device pixel ratio (dpr): rapporto tra

    pixel hardware e dip ➔ Initial-scale: rapporto tra dip e pixel CSS
  12. Le @media rules... @media screen { /* regole per screen

    */ } CSS <link rel=”stylesheet” type=”text/css” media=”handheld” href=”handheld.css” /> HTML
  13. ...e le @media query @media screen and (min-width: 760px) {

    /* regole per schermi di almeno 760px */ } CSS medium aggiungiamo condizioni la media feture
  14. media features • width • height • min-width • min-height

    • max-width • max-height • orientation • ... valore landscape o portrait
  15. @media query, un esempio @media screen and (min-width: 320px) {

    .wrap { background-color: #AA3939; } } @media screen and (min-width: 760px) { .wrap { background-color: #183F98; } } CSS
  16. @media query, altro esempio @media screen and (min-width: 320px) {

    .sidebar, .content { float: none; } } @media screen and (min-width: 760px) { .sidebar { float: left; } .content { float: right; } } CSS
  17. Tutto assieme e... Il layout fluido collega le diverse visualizzazioni

    di un sito, tra un breakpoint e il successivo.
  18. Cosa abbiamo visto: • Il web è universale • 4

    approcci: fixed, fluid, adaptive e responsive • Target ÷ Context nei layout fluid • La viewport e i pixel • Le media query • Tutto assieme!
  19. Gli obiettivi: 1) Esaminare il codice del sito demo 2)

    Impostare il testo in unità relative (em) 3) Impostare width, margin e padding in unità relative (%) 4) Resettare la viewport 5) Identificare i breakpoint 6) Modificare il layout in corrispondenza dei breakpoint
  20. Restiamo in contatto! ★ Jacopo Rabolini | Web & Graphic

    designer ➔ jacoporabolini.com ➔ [email protected] ➔ google.com/+jacoporabolini