{"id":365,"date":"2015-10-19T18:00:14","date_gmt":"2015-10-19T09:00:14","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=365"},"modified":"2015-10-20T10:11:01","modified_gmt":"2015-10-20T01:11:01","slug":"svg_css3_transform_sp2","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2015\/10\/svg_css3_transform_sp2\/","title":{"rendered":"JavaScript\u304b\u3089SVG\u306eCSS\u30fbStyle\u3092\u64cd\u4f5c\u3057\u3066\u7acb\u65b9\u4f53\u3092\u56de\u8ee2\u3055\u305b\u308b"},"content":{"rendered":"<p>SVG\u30676\u679a\u306e\u30d1\u30cd\u30eb\u3092\u751f\u6210\u3057\u3001 transform-style: preserve-3d \u3084 transform:rotate()\u306a\u3069\u3092CSS\u3067\u6307\u5b9a\u3057\u7acb\u65b9\u4f53\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u304b\u3089\u7acb\u65b9\u4f53\u3092\u542b\u3080div\u306b\u5bfe\u3057\u3066\u3001JavaScript\u304b\u3089 setInterval \u3092\u3064\u304b\u3044CSS\u306etransform:rotate\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>  <!--more--><br \/>\n\u2193\u4ee5\u4e0b\u304c\u5b9f\u969b\u306e\u30bd\u30fc\u30b9\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<p>\u25bcJavaScript<\/p>\n<pre class=\"lang:js decode:true \" title=\"JavaScript\" >\r\n<script>\r\n\tvar degX =0;\r\n\tvar degY =0;\r\n\tvar degZ =0;\r\n\r\n\tvar svg_x = document.getElementById(\"group_1\");\r\n\tvar svg_y = document.getElementById(\"group_2\");\r\n\tvar svg_z = document.getElementById(\"group_3\");\r\n\r\n\tsetInterval(\"draw()\",33);\r\n\r\nfunction draw(){\r\n\tdegX=(degX+1+360)%360;\r\n\tdegY=(degY+2+360)%360;\r\n\tdegZ=(degZ+3+360)%360;\r\n\txyz=\"rotateX(\"+degX+\"deg) rotateY(\"+degY+\"deg) rotateZ(\"+degZ+\"deg)\";\r\n\tvar container = document.getElementById(\"container\");\r\n\tcontainer.style.transform = xyz;\r\n}\r\n<\/script>\r\n<\/pre>\n<p>\u25bcCSS<\/p>\n<pre class=\"lang:css decode:true \" title=\"CSS\" >\r\n<style>\r\n\r\n#container{\r\n\ttransform-style: preserve-3d;\r\n\twidth:400px;\r\n\theight:400px;\r\n\tposition:relative;\r\n\ttransform-origin:300px 300px;\r\n\ttransform:rotateX(-45deg) rotateY(-45deg);\r\n}\r\n\r\nsvg{\r\n\ttransform-style: preserve-3d;\r\n\tposition:absolute;\r\n\twidth:600px;\r\n\theight:600px;\r\n}\r\n.number{\r\n\tfont-size:200px;\r\n}\r\n\r\n\r\nsvg#group_1{\r\n\ttransform:translateZ(100px);\r\n}\r\n\r\nsvg#group_2{\r\n\ttransform: rotateX(90deg) translateZ(100px);\r\n}\r\n\r\nsvg#group_3{\r\n\ttransform:rotateY(90deg) translateZ(100px);\r\n}\r\n\r\nsvg#group_4{\r\n\ttransform:rotateY(270deg) rotateZ(180deg) translateZ(100px);\r\n}\r\nsvg#group_5{\r\n\ttransform:rotateX(270deg) rotateZ(180deg) translateZ(100px);\r\n}\r\nsvg#group_6{\r\n\ttransform:rotateX(180deg) translateZ(100px);\r\n}\r\n\r\nline{\r\n\tstroke-width:5;\r\n}\r\n#line_2{\r\n\ttransform:rotateY(90deg);\r\n}\r\n#line_3{\r\n\ttransform:rotateZ(90deg);\r\n}\r\n\r\nrect{\r\n\topacity:0.7;\r\n}\r\n#rect_1{\r\n\tfill:#00f;\r\n}\r\n#rect_2{\r\n\tfill:#f00;\r\n}\r\n#rect_3{\r\n\tfill:#0f0;\r\n}\r\n#rect_4{\r\n\tfill:#ff0;\r\n}\r\n#rect_5{\r\n\tfill:#0ff;\r\n}\r\n#rect_6{\r\n\tfill:#f0f;\r\n}\r\n\r\nline{\r\n\tstroke:black;\r\n\tstroke-width:3;\r\n}\r\ntext{\r\nheight:200;\r\nwidth:200;\r\nfont-size:200px;\r\n}\r\n<\/style>\r\n<\/pre>\n<p>\u25bcHTML<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"XHTML\" >\r\n<div id=\"container\">\r\n\t<svg id=\"line_1\" viewBox=\"-200 -200 600 600\">\r\n   \t\t<line id=\"line_1\" x1=\"-100\" y1=\"100\" x2=\"300\" y2=\"100\" \/>\r\n\t<\/svg>\r\n\t<svg id=\"line_2\" viewBox=\"-200 -200 600 600\">\r\n   \t\t<line id=\"line_1\" x1=\"-100\" y1=\"100\" x2=\"300\" y2=\"100\" \/> \r\n\t<\/svg>\r\n\t<svg id=\"line_3\" viewBox=\"-200 -200 600 600\">\r\n   \t\t<line id=\"line_1\" x1=\"-100\" y1=\"100\" x2=\"300\" y2=\"100\" \/> \r\n\t<\/svg>\r\n\r\n   \t<svg class=\"panel\" id=\"group_1\" viewBox=\"-200 -200 600 600\">\r\n\t\t<rect id=\"rect_1\" height=\"200\" width=\"200\" \/>\r\n       \t<text x=\"45\" y=\"175\">1<\/text>\r\n\t<\/svg>\r\n\t<svg class=\"panel\" id=\"group_2\" viewBox=\"-200 -200 600 600\">\r\n\t\t<rect id=\"rect_2\" height=\"200\" width=\"200\" \/>\r\n   \t    <text x=\"45\" y=\"175\">2<\/text>\r\n\t<\/svg>\r\n\t<svg class=\"panel\" id=\"group_3\" viewBox=\"-200 -200 600 600\">\r\n\t\t<rect id=\"rect_3\" height=\"200\" width=\"200\" \/>\r\n   \t    <text x=\"45\" y=\"175\">3<\/text>\r\n\t<\/svg>\r\n\t<svg class=\"panel\" id=\"group_4\" viewBox=\"-200 -200 600 600\">\r\n\t\t<rect id=\"rect_4\" height=\"200\" width=\"200\" \/>\r\n        <text x=\"45\" y=\"175\">4<\/text>\r\n\t<\/svg>\r\n\t<svg class=\"panel\" id=\"group_5\" viewBox=\"-200 -200 600 600\">\r\n\t\t<rect id=\"rect_5\" height=\"200\" width=\"200\" \/>\r\n        <text x=\"45\" y=\"175\">5<\/text>\r\n\t<\/svg>\r\n\t<svg class=\"panel\" id=\"group_6\" viewBox=\"-200 -200 600 600\">\r\n\t\t<rect id=\"rect_6\" height=\"200\" width=\"200\" \/>\r\n        <text x=\"45\" y=\"175\">6<\/text>\r\n\t<\/svg>\r\n<\/div>\r\n<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/svg_css3_transform_sp2\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SVG\u30676\u679a\u306e\u30d1\u30cd\u30eb\u3092\u751f\u6210\u3057\u3001 transform-style: preserve-3d \u3084 transform:rotate()\u306a\u3069\u3092CSS\u3067\u6307\u5b9a\u3057\u7acb\u65b9\u4f53\u306b\u3057\u307e\u3059\u3002 \u305d\u3053\u304b\u3089\u7acb\u65b9\u4f53\u3092\u542b\u3080div\u306b\u5bfe\u3057\u3066\u3001JavaScri [&hellip;]<\/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\/365"}],"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=365"}],"version-history":[{"count":4,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"predecessor-version":[{"id":373,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/365\/revisions\/373"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}