[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Upgrade to Pro — share decks privately, control downloads, hide ads and more …

こんなCSSからはそろそろ卒業しよう

 こんなCSSからはそろそろ卒業しよう

社内向け勉強会で作ったスライド

※Bracketsの拡張機能「Shizimily Multiencoding for Brackets」は最新Bracketsにはいらないようです!

Chiaki Okamoto

October 14, 2017
Tweet

More Decks by Chiaki Okamoto

Other Decks in Technology

Transcript

  1. ϨΨγʔϒϥ΢β༻ͷهड़͸ফͦ͏ ϨΨγʔϒϥ΢βʹʢಛʹIEΛࢦ͠·͕͢ʣࠓ͸͋·Γ࢖ΘΕͯ ͍ͳ͍ݹ͍ϒϥ΢βͷ͜ͱͰ͢ɻ width /***/: auto;ͱ͔* html .clearfix { zoom:

    1; }ͱ͍ͬͨهड़ ͸ɺओʹIE6ͱ͔IE7ͷͱͬͬͬͬͬͯ΋ݹ͍ϒϥ΢β༻ͷهड़ͳ ͷͰɺࠓ͸΋͏ॻ͔ͳͯ͘େৎ෉Ͱ͢ʂ
  2. CSSͷద༻ॱΛҙࣝͯ͠ΈΑ͏ .box { border: 1px solid #000; background: #f00; width:

    300px; height: 300px; border: 2px dotted #999; } Question! (A)෯300pxɺߴ͞300pxͰɺഎܠ͕#f00ͷɺ৭͕#999ͷ2pxυοτઢ͕͍͍ͭͯΔ (B)෯300pxɺߴ͞300pxͰɺഎܠ͕#f00ͷɺ৭͕#000ͷ1px௚ઢ͕͍͍ͭͯΔ (C)ϒϥ΢βʹΑͬͯ·ͪ·ͪ
  3. CSSͷద༻ॱΛҙࣝͯ͠ΈΑ͏ .box { width: 300px; } .box { width: 400px;

    } Question! (A)෯300px (B)෯400px (C)ϒϥ΢βʹΑͬͯ·ͪ·ͪ
  4. CSSͷద༻ॱΛҙࣝͯ͠ΈΑ͏(Ԡ༻) .wrap .box { width: 300px; } .box { width:

    400px; } Question! (A)෯300px (B)෯400px (C)͜Ε͸ؒҧ͍ͳ͘ϒϥ΢βʹΑͬͯ·ͪ·ͪ
  5. ϕϯμʔϓϨϑΟοΫεͷॱ൪ (A) .hoge { -webkit-box-sizing: border-box; box-sizing: border-box; } (B)

    .hoge { box-sizing: border-box; -webkit-box-sizing: border-box; } Question!
 ॻ͖ํ͸Ͳ͕ͬͪਖ਼͍͠Ͱ͠ΐ͏ʁ
  6. line-height .text { font-size: 10px; line-height: 12px; } @media (min-width:

    768px) { .text { font-size: 16px; line-height: 18px; } }
  7. ͭ·Γɺ͜Μͳײ͡ʹʂ .text { font-size: 10px; line-height: 1.6; } @media (min-width:

    768px) { .text { font-size: 16px; } } // εϚϗͷͱ͖͸((10*1.6)-10)/2 Ͱɺ্Լ3pxͷߦؒ // PC͸((16*1.6)-16)/2 Ͱɺ্Լ4.8pxͷߦؒ
  8. ॏෳ͢Δهड़Λ·ͱΊΑ͏ .text-a { text-align: left; font-size: 20px; color: #000; }

    .text-b { text-align: left; font-size: 50px; color: #000; } .text-c { text-align: left; color: #000; }
  9. ॏෳ͢Δهड़Λ·ͱΊΑ͏ .text-a, .text-b, .text-c { text-align: left; color: #000; }

    .text-a { font-size: 20px; } .text-b { font-size: 50px; }
  10. ઌఔͷॏෳΫϥε΋ڞ௨Խ .textset { text-align: left; color: #000; } .text-a {

    font-size: 20px; } .text-b { font-size: 50px; } // HTML <div class=“textset text-a”></div> <div class=“textset text-b”></div>
  11. margin͸৺ͷڑ཭ <div class=“a”></div> <div class=“b”></div> // CSS .a { margin:

    40px 0; } .b { margin-top: 20px; } Question .bͷ্ʹͭ͘margin͸Կpxʁ