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

Responsive Web Design もう一度

mantangs
February 04, 2018

Responsive Web Design もう一度

HTML5j Web プラットフォーム研究部 第20回講演資料

レスポンシブWebデザインでウェブサイトを構築する際に、大切なメディアクエリの取扱について、いかに減らすかについて。

Web Directions East 合同会社
菊池聡

mantangs

February 04, 2018
Tweet

More Decks by mantangs

Other Decks in Technology

Transcript

  1. RWD in 2018 •Fluid Image - Res Image •Fluid Grid

    - Flex&grid •Media Query-͔ΘΓͳ͠
  2. How do you efficiently scale up / down any UI

    component (e.g. a slider or calendar) and keep all the proportions intact—without fiddling with width, height or border-radius manually? — @simurai
  3. By sneaking a Trojan horse into your components. We use

    rem for components “root” and em for sub- parts of the components. Then, by adjusting the font-size of the root, we adjust all size-related CSS properties of a component at once. 
 — @simurai
  4. .button__delete{ border-radius: 50%; display: table-cell; color: white; background: red; font-size:

    1.25rem; width: 7.5vw; height: 7.5vw; line-height: 0; cursor: pointer; }
  5. .button__delete{ border-radius: 50%; display: table-cell; color: white; background: red; font-size:

    1.25rem; width: 7.5vim; height: 7.5vim; line-height: 0; cursor: pointer; }
  6. .button__delete{ border-radius: 50%; display: table-cell; color: white; background: red; font-size:

    1.25rem; width: calc (???); height: calc (???); line-height: 0; cursor: pointer; }
  7. .button__delete{ border-radius: 50%; display: table-cell; color: white; background: red; font-size:

    1.25rem; width: calc (1cm + 1.5vmin); height: calc (1cm + 1.5vmin); line-height: 0; cursor: pointer; }
  8. m = slope
 x = current viewport width b =

    the y-intercept
 y = resulting font size Image credit: Jake Wilson, https://www.smashingmagazine.com/2017/05/fluid-responsive-typography-css-poly-fluid-sizing/ https://www.smashingmagazine.com/author/jake-wilson/
  9. :root { /* scale for 1.2 */ --ms-small-1: 1rem; --ms-small-2:

    1.2rem; --ms-small-3: 1.44rem; --ms-small-4: 1.728rem; --ms-small-5: 2.074rem; --ms-small-6: 2.488rem; /* scale for 1.33 */ --ms-large-1: 1rem; --ms-large-2: 1.333rem; --ms-large-3: 1.777rem; --ms-large-4: 2.369rem; --ms-large-5: 3.157rem; --ms-large-6: 4.209rem; } IUUQTXXXNBEFCZNJLFDPNBVXSJUJOHVTJOHDTTWBSJBCMFT
  10. /* Small scale for small screens: */ h1 { font-size:

    var(--ms-small-6); } h2 { font-size: var(--ms-small-5); } h3 { font-size: var(--ms-small-4); } h4 { font-size: var(--ms-small-3); } h5 { font-size: var(--ms-small-2); } h6 { font-size: var(--ms-small-1); } /* And large scale for larger screens */ @media screen and (min-width: 800px) { h1 { font-size: var(--ms-large-6); } h2 { font-size: var(--ms-large-5); } h3 { font-size: var(--ms-large-4); } h4 { font-size: var(--ms-large-3); } h5 { font-size: var(--ms-large-2); } h6 { font-size: var(--ms-large-1); } } IUUQTXXXNBEFCZNJLFDPNBVXSJUJOHVTJOHDTTWBSJBCMFT
  11. h1 { font-size: var(--font-size-6); } h2 { font-size: var(--font-size-5); }

    h3 { font-size: var(--font-size-4); } h4 { font-size: var(--font-size-3); } h5 { font-size: var(--font-size-2); } h6 { font-size: var(--font-size-1); } IUUQTXXXNBEFCZNJLFDPNBVXSJUJOHVTJOHDTTWBSJBCMFT
  12. :root { /* scale for 1.2 */ --font-size-1: 1rem; --font-size-2:

    1.2rem; --font-size-3: 1.44rem; --font-size-4: 1.728rem; --font-size-5: 2.074rem; --font-size-6: 2.488rem; } @media screen and (min-width: 800px) { :root { /* scale for 1.33 */ --font-size-1: 1rem; --font-size-2: 1.333rem; --font-size-3: 1.777rem; --font-size-4: 2.369rem; --font-size-5: 3.157rem; --font-size-6: 4.209rem; } IUUQTXXXNBEFCZNJLFDPNBVXSJUJOHVTJOHDTTWBSJBCMFT
  13. /* σϑΥϧτͷࢦఆ */ :root { --font-size: 1.2rem; --background-color: #fff; --text-color:

    #222; } /* asideͷࢦఆ */ aside { --font-size: 1rem; --background-color: #222; --text-color: #fafafa; } /* ಉ݁͡Ռ */ main, aside { font-size: var(--font-size); color: var(--text-color); background-color: var(--background-color); }
  14. :root { --font-family: tondo_rg, sans-serif; --font-family-light: tondo_lt, sans-serif; --font-family-bold: tondo_bd,

    sans-serif; --font-weight: 400; --font-size-xxx-display: 8vmin; --font-size-xx-display: 4.11rem; --font-size-x-display: 3.653rem; --font-size-display: 3.247rem; --font-size-xxxx-large: 2.887rem; --font-size-xxx-large: 2.027rem; --font-size-xx-large: 1.802rem; --font-size-x-large: 1.602rem; --font-size-large: 1.424rem; --font-size-medium: 1.266rem; --font-size: 1.125rem; --font-size-small: 1rem; --font-size-x-small: .889rem; --font-size-xx-small: .79rem; --lineheight-text: 1.5; --lineheight-heading: 1.3; --color-background: #fff; --color-background-selection: #f0f2f3; --color-border: #cacfd5; --color-text-default: #0b1016; --color-text-alt: #95a0ac;
  15. @supports (display: flex) { div { display: flex; } }

    https://developer.mozilla.org/en-US/docs/Web/CSS/%40supports
  16. @supports not (display: flex) { div { float: right; }

    } https://developer.mozilla.org/en-US/docs/Web/CSS/%40supports