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

Sassと仲良くお付き合い

 Sassと仲良くお付き合い

2013年5月18日に開催された WCAF Vol.10 でのスライドです

Avatar for Toshiaki Sasaki

Toshiaki Sasaki

May 18, 2013
Tweet

More Decks by Toshiaki Sasaki

Other Decks in Design

Transcript

  1. .scss .css Nesting ೖΕࢠͰ$44Λॻ͚Δ #header { width: 960px; margin: 0

    auto; padding: 0; .contact { float: right; p { margin-bottom: 20px; } } } #header { width: 960px; margin: 0 auto; padding: 0; } #header .contact { float: right; } #header .contact p { margin-bottom: 20px; }
  2. .scss .css Valiables ม਺Λ࢖͏͜ͱ͕Ͱ͖Δ $secbottom: 30px; $basecolor: #cc0000; .block-a {

    background: $basecolor; margin-bottom: $secbottom; } .block-a { background: #cc0000; margin-bottom: 30px }
  3. .scss .css mixin $44ͷ·ͱ·ΓΛม਺Έ͍ͨʹ͢Δ @mixin sprite { display: block; text-indent:

    -9999px; } @mixin sectionWidth($dist) { width: $dist; margin: 0 auto; } .btn { @include sprite; } .btn { @include sectionWidth(960px); } .btn { display: block; text-indent: -9999px; } .btn { width: 960px; margin: 0 auto; }
  4. .scss .css extend ηϨΫλΛ࠶ར༻Ͱ͖Δ %clearfix { overflow: hidden; *zoom: 1;

    } #header { @extend: %clearfix; width: 980px; } #footer { @extend: %clearfix; width: 700px; } #header, #footer { overflow: hidden; *zoom: 1; } #header { width: 980px; } #footer { width: 700px; }
  5. .scss .css darken ৭Λ҉͘͢Δ $basecolor: #eee; .block-a { width: 100px;

    height: 100px; background: $basecolor; } .block-b { width: 100px; height: 100px; background: darken($basecolor, 30%); } .block-a { width: 100px; height: 100px; background: #eeeeee; } .block-b { width: 100px; height: 100px; background: #a2a2a2; }
  6. .scss .css lighten ৭Λ໌Δ͘͢Δ $basecolor: #990000; .block-a { width: 100px;

    height: 100px; background: $basecolor; } .block-b { width: 100px; height: 100px; background: lighten($basecolor, 30%); } .block-a { width: 100px; height: 100px; background: #990000; } .block-b { width: 100px; height: 100px; background: #ff3333; }
  7. .scss .css mixin ͋Β͔͡ΊNJYJO͕ͨ͘͞Μ༻ҙ͞Ε͍ͯΔ @import “compass/css3”; .block-a { @include border-radius(10px);

    } .block-b { @include box-shadow(#c00 3px 3px 10px); } .block-a { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px; } .block-b { -webkit-box-shadow: #cc0000 3px 3px 10px; -moz-box-shadow: #cc0000 3px 3px 10px; box-shadow: #cc0000 3px 3px 10px;
  8. .scss .css CSS Sprite DTTͱը૾ΛࣗಈͰ࡞ͬͯ͘ΕΔ @import “icons/.png”; @include all-icons-sprite; //

    img/icons ʹΞΠίϯը૾ // config.rb ͷը૾ύεઃఆ͸ ɹɹimages_dir = "img" .icons-sprite, .icons-download, .icons-cloud { background: url(‘../img/icons- scb48544681.png’) no-repeat; } .icons-sprite { background-position: 0 32px; } .icons-download { background-position: 0 64px; } .icons-cloud { background-position: 0 96px; }
  9. .scss CSS sprite + image-width,height $icon: sprite-map(“path”, $spacing: 5px); @mixin

    sprite { display: block; text-indent: -9999px; } .icon-cloud { @include sprite; width: image-width(sprite-file($icon, imagename)); height: image-height(sprite-file($icon, imagename)); background-image: $icon; background-position: sprite-position($icon, imagename); }
  10. DBTF QW Q css _scss _common.scss _valiables.scss _module.scss style.css _spriteimage.scss

    style.scss ɾ ɾ ɾ αΠτͷ࿮૊Έ ม਺ ύʔπ $44εϓϥΠτ ֤ίϯςϯπ༻
  11. config.rb http_path = "/" css_dir = "css" sass_dir = "_scss"

    images_dir = "img" javascripts_dir = "js" output_style = :nested relative_assets = true line_comments = false DTTͷϑΥϧμ໊ TBTTͷϑΥϧμ໊ ը૾ͷϑΥϧμ໊ +BWB4DSJQUͷϑΥϧμ໊ DTTͷग़ྗܗࣜ ૬ରύεʢTQSJUFͷͨΊʹඞཁʣ TDTTͷԿߦ໨͔Λίϝϯτ͚ͭΔ
  12. DBTF QW Q css _scss _common.scss _company.scss style.css _price.scss style.scss

    ɾ ɾ ɾ _item.scss ҰͭͷDTTϑΝΠϧʹίϯύΠϧ͢ΔͷͰ ҧ͏TDTTϑΝΠϧΛෳ਺ਓͰ࡞ۀͯ͠΋େৎ෉ style.css