{"id":331,"date":"2015-10-15T14:36:24","date_gmt":"2015-10-15T05:36:24","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=331"},"modified":"2015-10-15T14:37:01","modified_gmt":"2015-10-15T05:37:01","slug":"svgcube","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2015\/10\/svgcube\/","title":{"rendered":"SVG\u3092\u4f7f\u3063\u3066\u7acb\u65b9\u4f53\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f"},"content":{"rendered":"<p><!-- \u672c\u6587 --><\/p>\n<p>SVG\u30bf\u30b0\uff08\u8981\u7d20\uff09\u3092\u4f7f\u3063\u3066\u6b63\u516d\u9762\u4f53\u306e\u7acb\u65b9\u4f53\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br \/>\n<!--more--><\/p>\n<p>\uff11\u3001\u7acb\u65b9\u4f53\u3092\u5f62\u6210\u3059\u308b\uff16\u753b\u9762\u3092SVG\u30bf\u30b0\u3092\u4f7f\u7528\u3057\u3066\u4f5c\u6210\u3059\u308b\u3002<br \/>\n\u3000HTML\u4f8b\u6587:SVG\u30bf\u30b0\uff08200px\u306e\u6b63\u65b9\u5f62\u3092\uff16\u753b\u9762\u5206\u4f5c\u6210\uff09<br \/>\n\u3000\u3000\u3000&lt;svg class=&#8221;surface&#8221; id=&#8221;front&#8221; viewBox=&#8221;100 100 200 200&#8243; &gt;<br \/>\n\u3000\u3000\u3000\u3000&lt;rect x=&#8221;100&#8243; y=&#8221;100&#8243; width=&#8221;200&#8243; hight=&#8221;200&#8243; \/&gt;<br \/>\n\u3000\u3000\u3000\u3000&lt;text x=&#8221;150&#8243; y=&#8221;240&#8243;&gt;1&lt;\/text&gt;<br \/>\n\u3000\u3000\u3000&lt;\/svg&gt;<br \/>\n\u3000a.200px\u306e\u6b63\u65b9\u5f62\u3092\u4f5c\u6210\u3059\u308b\u3002\u4f8b\u3067\u306f\u3001X\u8ef8\u306b100px\u3001Y\u8ef8\u306b100px\u306e\u4f4d\u7f6e\u304b\u3089200px\u306e\u6b63\u65b9\u5f62\u3092\u4f5c\u6210\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\uff12\u3001\u6b63\u9762\u306e\u4f4d\u7f6e\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#front{transform: translateZ(100px);}<br \/>\n\u3000a.\u300ctranslateZ(100px)\u300dZ\u8ef8\u306b100px\u79fb\u52d5\u3055\u305b\u308b\u3002<\/p>\n<p>\uff13\u3001\u88cf\u9762\u306e\u4f4d\u7f6e\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#back{transform: rotateX(180deg) translateZ(100px);}<br \/>\n\u3000a.\u300ctranslateZ(100px)\u300dZ\u8ef8\u306b100px\u79fb\u52d5\u3055\u305b\u308b\u3002<br \/>\n\u3000b.\u300crotateX(180deg)\u300dX\u8ef8\u306b180\u00b0\u56de\u8ee2\u3055\u305b\u308b\u3002\u56de\u8ee2\u3055\u305b\u308b\u4e8b\u306b\u3088\u308a\u6b63\u9762\u3068\u88cf\u9762\u306e\u9593\u306b200px\u306e\u5e45\u304c\u51fa\u6765\u308b\u3002<\/p>\n<p>\uff14\u3001\u53f3\u9762\u306e\u4f4d\u7f6e\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#right{transform: rotateY(90deg) translateZ(100px);}<br \/>\n\u3000a.\u300ctranslateZ(100px)\u300dZ\u8ef8\u306b100px\u79fb\u52d5\u3055\u305b\u308b\u3002<br \/>\n\u3000b.\u300crotateY(90deg)\u300dY\u8ef8\u306b90\u00b0\u56de\u8ee2\u3055\u305b\u308b\u3002\u56de\u8ee2\u3055\u305b\u308b\u3068\u6b63\u9762\u306e\u53f3\u7aef\u304b\u3089\u76f4\u89d2\u306b\u66f2\u304c\u308a\u88cf\u9762\u3068\u7e4b\u304c\u308b\u3002<\/p>\n<p>\uff15\u3001\u5de6\u9762\u306e\u4f4d\u7f6e\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#left{transform: rotateY(-90deg) translateZ(100px);}<br \/>\n\u3000a.\u300ctranslateZ(100px)\u300dZ\u8ef8\u306b100px\u79fb\u52d5\u3055\u305b\u308b\u3002<br \/>\n\u3000b.\u300crotateY(-90deg)\u300dY\u8ef8\u306b90\u00b0\u56de\u8ee2\u3055\u305b\u308b\u3002\u56de\u8ee2\u3055\u305b\u308b\u3068\u6b63\u9762\u306e\u5de6\u7aef\u304b\u3089\u76f4\u89d2\u306b\u66f2\u304c\u308a\u88cf\u9762\u3068\u7e4b\u304c\u308b\u3002<\/p>\n<p>\uff16\u3001\u4e0a\u9762\u306e\u4f4d\u7f6e\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#top{transform: rotateX(90deg) translateZ(100px);}<br \/>\n\u3000a.\u300ctranslateZ(100px)\u300dZ\u8ef8\u306b100px\u79fb\u52d5\u3055\u305b\u308b\u3002<br \/>\n\u3000b.\u300crotateY(90deg)\u300dX\u8ef8\u306b90\u00b0\u56de\u8ee2\u3055\u305b\u308b\u3002\u56de\u8ee2\u3055\u305b\u308b\u3068\u6b63\u9762\u306e\u4e0a\u7aef\u304b\u3089\u76f4\u89d2\u306b\u66f2\u304c\u308a\u5de6\u53f3\u88cf\u9762\u306e\u4e0a\u90e8\u304c\u7e4b\u304c\u308b\u3002<\/p>\n<p>\uff17\u3001\u4e0b\u9762\u306e\u4f4d\u7f6e\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#bottom{transform: rotateX(-90deg) translateZ(100px);}<br \/>\n\u3000a.\u300ctranslateZ(100px)\u300dZ\u8ef8\u306b100px\u79fb\u52d5\u3055\u305b\u308b\u3002<br \/>\n\u3000b.\u300crotateY(-90deg)\u300dX\u8ef8\u306b90\u00b0\u56de\u8ee2\u3055\u305b\u308b\u3002\u56de\u8ee2\u3055\u305b\u308b\u3068\u6b63\u9762\u306e\u4e0b\u7aef\u304b\u3089\u76f4\u89d2\u306b\u66f2\u304c\u308a\u5de6\u53f3\u88cf\u9762\u306e\u4e0b\u90e8\u304c\u7e4b\u304c\u308b\u3002<\/p>\n<p>\uff18\u3001\u6b63\u516d\u9762\u4f53\u306e\u5168\u4f53\u3092\u50be\u659c\u3055\u305b\u3066\u7acb\u65b9\u4f53\u3068\u3057\u3066\u898b\u305b\u308b\u3002<br \/>\n\u3000CSS\u4f8b\u6587\uff1a#cube{transform-style: preserve-3d;,transform: rotateX(-20deg) rotateY(-20deg);}<br \/>\n\u3000a.\u300ctransform-style: preserve-3d\u300d\u3067\uff13\uff24\u7a7a\u9593\u306e\u4e2d\u3067\u5b50\u8981\u7d20\u304c\u305d\u308c\u305e\u308c\u306e\u4f4d\u7f6e\u3092\u7dad\u6301\u3059\u308b\u3088\u3046\u306b\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000b.\u300ctransform: rotateX(-20deg) rotateY(-20deg);\u300d\u306b\u3066\u3001\uff38\u8ef8\uff64Y\u8ef8\u305d\u308c\u305e\u308c\u306b-20\u00b0\u50be\u659c\u3055\u305b\u308b\u3002<br \/>\n\u3000\u3000\u6b63\u9762\u3057\u304b\u898b\u3048\u3066\u3044\u306a\u304b\u3063\u305f\u304c\u3001X\u8ef8Y\u8ef8\u306b\u5bfe\u3057\u3066\u50be\u659c\u3092\u4ed8\u3051\u308b\u4e8b\u3067\u7acb\u65b9\u4f53\u306b\u898b\u3048\u308b\u69d8\u306b\u306a\u308b\u3002<\/p>\n<p>\uff19\u3001\u305d\u306e\u4ed6\u306e\u6ce8\u610f\u70b9<br \/>\n\u3000a.\uff16\u753b\u9762\u306e\u57fa\u6e96\u70b9\u304c\u540c\u3058\u70b9\u3068\u6210\u308b\u69d8\u306b\u3001CSS\u306b\u3066\u300cposition\u300d\u3092\u4f7f\u3044\u57fa\u6e96\u70b9\u3092\u5408\u308f\u305b\u308b\u3002<br \/>\n\u3000b.\u4f8b\u6587\u306e\u69d8\u306bSVG\u30bf\u30b0\uff08\u8981\u7d20\uff09\u306b\u300ctransform\u300d\u3092\u6307\u5b9a\u3059\u308b\u70ba\u3001rect\u30bf\u30b0\uff08\u8981\u7d20\uff09\u6bce\u306bSVG\u30bf\u30b0\uff08\u8981\u7d20\uff09\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n\u3000\u3000rect\u30bf\u30b0\uff08\u8981\u7d20\uff09\u306b\u300ctransform\u300d\u3092\u540c\u3058\u69d8\u306b\u5b9a\u7fa9\u3057\u3066\u3082\u7acb\u65b9\u4f53\u306f\u51fa\u6765\u306a\u3044\u3002<\/p>\n<p>\u2193\u4ee5\u4e0b\u304c\u30c6\u30b9\u30c8\u306e\u30bd\u30fc\u30b9\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<p>\u25bcCSS<\/p>\n<pre class=\"lang:css decode:true \" title=\"CSS\" >&lt;style type=\"text\/css\"&gt;\r\nbody{\r\n\twidth: 100%;\r\n\theight:100%;\r\n}\r\n#wrap {\r\n\tmargin:200px 200px;\r\n}\r\n#cube {\r\n\tposition: relative;\r\n\ttransform-style: preserve-3d;\r\n\ttransform: rotateX(-20deg) rotateY(-20deg);\r\n}\r\n.surface {\r\n\tposition: absolute;\r\n\tleft: 0;\r\n\ttop: 0;\r\n\twidth: 200px;\r\n \theight: 200px;\r\n\ttext-align: center;\r\n\tline-height: 200px;\r\n\tbox-sizing: border-box;\r\n\tborder: 2px solid black;\r\n}\r\ntext{\r\n\tfill:black;\r\n\tfont-size:130px;\r\n}\r\n#front {\r\n\ttransform: rotateY(0deg) translateZ(100px);\r\n\tbackground:red;\/*\u8d64*\/\r\n\topacity: 0.6;\r\n}\r\n#back {\r\n\ttransform: rotateX(180deg) translateZ(100px);\r\n\tbackground:pink;\/*\u30d4\u30f3\u30af*\/\r\n\topacity: 0.6;\r\n}\r\n#right{\r\n\ttransform: rotateY(90deg) translateZ(100px);\r\n\tbackground:blue;\/*\u9752*\/\r\n\topacity: 0.6;\r\n}\r\n#left {\r\n\ttransform: rotateY(-90deg) translateZ(100px);\r\n\tbackground:skyblue;\/*\u6c34\u8272*\/\r\n\topacity: 0.6;\r\n}\r\n#top {\r\n\ttransform: rotateX(90deg) translateZ(100px);\r\n\tbackground:green;\/*\u7dd1*\/\r\n\topacity: 0.6;\r\n}\r\n#bottom {\r\n\ttransform: rotateX(-90deg) translateZ(100px);\r\n\tbackground:yellow;\/*\u9ec4\u8272*\/\r\n\topacity: 0.6;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<p>\u25bcHTML<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"HTML5\" >&lt;div id=\"wrap\"&gt;\r\n\t&lt;div id=\"cube\"&gt;\r\n\t\t&lt;svg class=\"surface\" id=\"front\" viewBox=\"100 100 200 200\" &gt;\r\n\t\t\t\t&lt;rect x=\"100\" y=\"100\" width=\"200\" hight=\"200\"&gt;&lt;\/rect&gt;\r\n\t\t\t\t&lt;text x=\"150\" y=\"240\"&gt;1&lt;\/text&gt;\r\n\t\t&lt;\/svg&gt;\r\n\t\t&lt;svg class=\"surface\" id=\"back\" viewBox=\"100 100 200 200\" &gt;\r\n\t\t\t\t&lt;rect x=\"100\" y=\"100\" width=\"200\" hight=\"200\"&gt;&lt;\/rect&gt;\r\n\t\t\t\t&lt;text x=\"150\" y=\"240\"&gt;2&lt;\/text&gt;\r\n\t\t&lt;\/svg&gt;\r\n\t\t&lt;svg class=\"surface\" id=\"right\" viewBox=\"100 100 200 200\" &gt;\r\n\t\t\t\t&lt;rect x=\"100\" y=\"100\" width=\"200\" hight=\"200\"&gt;&lt;\/rect&gt;\r\n\t\t\t\t&lt;text x=\"150\" y=\"240\"&gt;3&lt;\/text&gt;\r\n\t\t&lt;\/svg&gt;\r\n\t\t&lt;svg class=\"surface\" id=\"left\" viewBox=\"100 100 200 200\" &gt;\r\n\t\t\t\t&lt;rect x=\"100\" y=\"100\" width=\"200\" hight=\"200\"&gt;&lt;\/rect&gt;\r\n\t\t\t\t&lt;text x=\"150\" y=\"240\"&gt;4&lt;\/text&gt;\r\n\t\t&lt;\/svg&gt;\r\n\t\t&lt;svg class=\"surface\" id=\"top\" viewBox=\"100 100 200 200\" &gt;\r\n\t\t\t\t&lt;rect x=\"100\" y=\"100\" width=\"200\" hight=\"200\"&gt;&lt;\/rect&gt;\r\n\t\t\t\t&lt;text x=\"150\" y=\"240\"&gt;5&lt;\/text&gt;\r\n\t\t&lt;\/svg&gt;\r\n\t\t&lt;svg class=\"surface\" id=\"bottom\" viewBox=\"100 100 200 200\" &gt;\r\n\t\t\t\t&lt;rect x=\"100\" y=\"100\" width=\"200\" hight=\"200\"&gt;&lt;\/rect&gt;\r\n\t\t\t\t&lt;text x=\"150\" y=\"240\"&gt;6&lt;\/text&gt;\r\n\t\t&lt;\/svg&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/SvgCube\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SVG\u30bf\u30b0\uff08\u8981\u7d20\uff09\u3092\u4f7f\u3063\u3066\u6b63\u516d\u9762\u4f53\u306e\u7acb\u65b9\u4f53\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,3],"tags":[],"_links":{"self":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/331"}],"collection":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/comments?post=331"}],"version-history":[{"count":5,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":336,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/331\/revisions\/336"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}