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

ハマるSVG@CSS nite LP47

Naoki Matsuda
September 03, 2016

ハマるSVG@CSS nite LP47

Naoki Matsuda

September 03, 2016
Tweet

More Decks by Naoki Matsuda

Other Decks in Technology

Transcript

  1. ͸·Δʲቕ·Δɾర·Δɾṇ·Δʳ ᶃ ͽͬͨΓ߹ͬͯ͸͍Δɻ ᶄ ઒ɾ஑ͳͲʹམͪࠐΉɻʮਂΈʹʵɾΔʯʮߔʹʵɾΔʯʮՌ͸आۚͷ෵;ͪ ʹʵɾΓʗුӢ࢛໎ʯ ᶅ ܭུʹ͔͚ΒΕΔɻʮΘͳʹʵɾΔʯʮࢥ͏ͭ΅ʹʵɾΔʯ ᶆ ৚݅ʹͽͬͨΓ߹͏ɻద߹͢Δɻ͋ͯ͸·Δɻʮ໾ʹʵɾ͍ͬͯΔʯ

    ᶇ ʢʮܕʹ͸·ΔʯͷܗͰʣߦಈɾදݱͳͲ͕ྨܕతͰ͋Δɻʮܕʹʵɾͬͨจষʯ ʮܕʹʵɾͬͨڭҭʯ ᶈ ઐ೦͢Δɻ·ͨɼເதʹͳͬͯ਎ಈ͖͕ͱΕͳ͘ͳΔɻݱ୅Ͱ΋ଏޠతʹ༻͍Δɻ ʮࠓύιίϯʹʵɾ͍ͬͯΔʯʮੈؒϊࣄχʵɾϧʗ೔෤ʯʮਮΒ͖͠உ͸ʵɾ Βͤʗුੈ૲ࢠɾҰ୅உʯʤʮ͸ΊΔʯʹର͢Δࣗಈࢺʥ େࣙྛୈࡾ൛ΑΓ
  2. Standalone SVG )5.- $44 47( )5.- TWH TWH inline SVG

    兛鸐ך歗⫷ؿ؋؎ٕה׃ג邌爙ׇׁ׷ )5.-ך⚥חծ47(؝٦س׾湫䱸剅ֻ 兛鸐ך歗⫷ה殯ז׷暴䗙
  3. ז׈ 4BGBSJծ$44ָIFJHIU㾩䚍׾馄ִ׵׸זְ svg { height: auto; } QYח
 㔿㹀ׁ׸׷ )5.-$BOWBTך➬圫הずׄ

    <svg width="200px" height="200px" viewBox="0 0 200 200" style="width: 300px; height: auto"> IFJHIU㾩䚍ָ ⮚⯓ׁ׸׷
  4. 鍑寸 QBEEJOHIBDL׃׋EJW銲稆ד㔲ֲ div.svg-container .svg-wrap > svg { display: block; position:

    absolute; width: 100%; height: 100%; } .svg-container { position: relative; height:0; padding-top: calc(100%/200*200); } TWH
  5. 鍑寸 ،؎؝ٝ欽47(׾ծ)5.-חJOMJOFד㙵׭׷ index.html Send Mail <html> <body> <svg> <symbol id="icon1">…</symbol>

    <symbol id="icon2">…</symbol> … </svg> <svg><use xlink:href="icon.svg#icon1"/ ></svg> </body>
  6. <svg viewBox="0 0 250 250"> <image xlink:href="xxx.jpg" … class="clip-svg"/> </svg>

    .clip-svg { clip-path: url(#clipping); } <svg width="0" height="0"> <defs> <clipPath id="clipping"> <polygon … /> </clipPath> </defs> </svg> JNBHF銲稆 وأؙ欽ךDMJQ1BUI銲稆 $44
  7. 鍑寸 如ך銲稆⟃㢩⢪׻זְ • circle • clipPath • defs • ellipse

    • g • image • line • linearGradient • mask • path • pattern • polygon • polyline • radialGradient • rect • stop • svg • text • tspan
  8. 鍑寸 TZNCPM銲稆ծVTF銲稆כ⢪ִזְךדծ 3FBDUDSFBUF$MBTTד؝ٝه٦طٝز⻉ const IconUmbrella = React.createClass({ render() { return

    ( <svg className="umbrella" xmlns="http://www.w3.org/ 2000/svg" width="32" height="32" viewBox="0 0 32 32" aria- labelledby="title"><title id="title">Umbrella Icon</title><path d="M27 14h5c0-1.105-1.119-2-2.5-2s-2.5 0.82… z"/></svg> ) } }); https://css-tricks.com/creating-svg-icon-system-react/
  9. 鍑寸 <rect x="80" y="40" fill="#FFCC00" width="30" height="30"/> <path fill="#FFCC00" d="M201.3,61.8c-3.3-18.1,7-36.8,..."/>

    <polygon points="43.3,67.8 86.6,142.8 ..." fill="#FFCC00"/> QBUI銲稆ח㢌䳔׃ծ㾩䚍ך鎸鶢갫׾䲧ִծ H[JQ㖇簭׾遤ֲ