{"id":521,"date":"2016-03-29T15:06:11","date_gmt":"2016-03-29T06:06:11","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=521"},"modified":"2016-03-29T15:06:11","modified_gmt":"2016-03-29T06:06:11","slug":"slideattackbox2","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2016\/03\/slideattackbox2\/","title":{"rendered":"jQuery\u3067\u5185\u5bb9\u3092\u62bc\u3057\u3064\u3076\u3057\u3066\u6b21\u306e\u5185\u5bb9\u306b\u5207\u308a\u66ff\u308f\u308b\u30b9\u30e9\u30a4\u30c9\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\uff01"},"content":{"rendered":"<p> <!-- \u672c\u6587 --><\/p>\n<p>\u30b9\u30e9\u30a4\u30c9\u3059\u308b\u3068\u3001\u5185\u5bb9\u3092\u5de6\u53f3\u304b\u3089\u62bc\u3057\u3064\u3076\u3057\u3066\u3001\u6b21\u306e\u5185\u5bb9\u304c\u5de6\u53f3\u306e\u91cd\u308a\u3092\u306f\u3058\u304d\u8fd4\u3059\u3088\u3046\u306a\u30b9\u30e9\u30a4\u30c9\u3092jQuery\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30b9\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u2193\u4ee5\u4e0b\u304c\u5b9f\u969b\u306e\u30bd\u30fc\u30b9\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" title=\"\u25bcJavaScript\" >&lt;script&gt;\r\n$(function () {\r\n\t$(\"#main\").prepend(\"&lt;div class='left'&gt;&lt;\/div&gt;&lt;div class='right'&gt;&lt;\/div&gt;\");\r\n\t$(\".left\").css({\r\n\t\t\"left\": \"0%\",\r\n\t\t\"margin-left\": \"-\" + $(\".left\").width() + \"px\"\r\n\t});\r\n\t$(\".right\").css({\r\n\t\t\"left\": \"100%\",\r\n\t\t\"margin-left\": \"0\"\r\n\t});\r\n\t$(\".box\").css({\r\n\t\t\"position\": \"absolute\",\r\n\t\t\"left\": \"50%\",\r\n\t\t\"margin-left\": \"-\" + ($(\".box:eq(0)\").width() \/ 2) + \"px\"\r\n\t});\r\n\t$(\".box:gt(0)\").css({\r\n\t\t\"display\": \"none\"\r\n\t});\r\n\r\n\t$(\".box\").click(function () {\r\n\t\tvar $this = $(this),\r\n\t\t\t$thisNextBox = $(\"+.box\", this),\r\n\t\t\t$thisNextBoxWidth = $thisNextBox.width();\r\n\r\n\t\t$(\".left\").css({\r\n\t\t\t\"left\": \"0%\",\r\n\t\t\t\"margin-left\": \"-\" + $(\".left\").width() + \"px\"\r\n\t\t});\r\n\t\t$(\".right\").css({\r\n\t\t\t\"left\": \"100%\",\r\n\t\t\t\"margin-left\": \"0\"\r\n\t\t});\r\n\t\t$(\".box\").css({\r\n\t\t\t\"position\": \"absolute\",\r\n\t\t\t\"left\": \"50%\",\r\n\t\t\t\"margin-left\": \"-\" + ($(\".box:eq(0)\").width() \/ 2) + \"px\"\r\n\t\t});\r\n\t\t$(\".box:gt(0)\").css({\r\n\t\t\t\"display\": \"none\"\r\n\t\t});\r\n\r\n\t\t$(\".left\").animate({\r\n\t\t\t\"left\": \"50%\",\r\n\t\t\t\"margin-left\": \"-\" + ($(\".left\").width() + ($this.width() \/ 2)) + \"px\"\r\n\t\t}, function () {\r\n\t\t\t$this.animate({\r\n\t\t\t\t\"width\": \"0\",\r\n\t\t\t\t\"margin-left\": \"0\",\r\n\t\t\t}, 1500);\r\n\t\t\t$(\".left\").animate({\r\n\t\t\t\t\"left\": \"50%\",\r\n\t\t\t\t\"margin-left\": \"-\" + $(\".left\").width() + \"px\"\r\n\t\t\t}, 1500, function () {\r\n\t\t\t\t$this.css({\r\n\t\t\t\t\t\"width\": \"\",\r\n\t\t\t\t\t\"margin-left\": \"\",\r\n\t\t\t\t\t\"display\": \"none\"\r\n\t\t\t\t}).appendTo(\"#main\");\r\n\t\t\t\t$thisNextBox.css({\"width\":\"0\", \"display\": \"block\", \"margin-left\": \"0\"}).animate({\r\n\t\t\t\t\t\"width\": $thisNextBoxWidth + \"px\",\r\n\t\t\t\t\t\"margin-left\": \"-\" + ($thisNextBoxWidth \/ 2) + \"px\",\r\n\t\t\t\t});\r\n\t\t\t\t$(\".left\").animate({\r\n\t\t\t\t\t\"left\": \"0%\",\r\n\t\t\t\t\t\"margin-left\": \"-\" + $(\".left\").width() + \"px\"\r\n\t\t\t\t});\r\n\t\t\t\t$(\".right\").animate({\r\n\t\t\t\t\t\"left\": \"100%\",\r\n\t\t\t\t\t\"margin-left\": \"0\"\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t\t$(\".right\").animate({\r\n\t\t\t\t\"left\": \"50%\",\r\n\t\t\t\t\"margin-left\": \"0\"\r\n\t\t\t}, 1500);\r\n\t\t});\r\n\t\t$(\".right\").animate({\r\n\t\t\t\"left\": \"50%\",\r\n\t\t\t\"margin-left\": ($this.width() \/ 2) + \"px\"\r\n\t\t});\r\n\t});\r\n});\r\n&lt;\/script&gt;<\/pre>\n<pre class=\"lang:css decode:true \" title=\"\u25bcCSS\" >&lt;style&gt;\r\n\t\t* {\r\n\t\t\tmargin: 0;\r\n\t\t\tpadding: 0;\r\n\t\t\tborder: 0;\r\n\t\t}\r\n\r\n\t\tbody {\r\n\t\t\toverflow: hidden;\r\n\t\t}\r\n\r\n\t\t#main {\r\n\t\t\twidth: 100%;\r\n\t\t\tfont-size: 3em;\r\n\t\t\tfont-weight: bold;\r\n\t\t\ttext-align: center;\r\n\t\t}\r\n\r\n\t\t.box {\r\n\t\t\toverflow: hidden;\r\n\t\t}\r\n\r\n\t\t#box1 {\r\n\t\t\tdisplay: block;\r\n\t\t\tbackground: #f00;\r\n\t\t\twidth: 500px;\r\n\t\t\theight: 500px;\r\n\t\t\tmargin: 0 auto;\r\n\t\t}\r\n\r\n\t\t#box2 {\r\n\t\t\tdisplay: block;\r\n\t\t\tbackground: #0f0;\r\n\t\t\twidth: 500px;\r\n\t\t\theight: 500px;\r\n\t\t\tmargin: 0 auto;\r\n\t\t}\r\n\r\n\t\t#box3 {\r\n\t\t\tdisplay: block;\r\n\t\t\tbackground: #00f;\r\n\t\t\twidth: 500px;\r\n\t\t\theight: 500px;\r\n\t\t\tmargin: 0 auto;\r\n\t\t}\r\n\r\n\t\t#box4 {\r\n\t\t\tdisplay: block;\r\n\t\t\tbackground: #ccc;\r\n\t\t\twidth: 500px;\r\n\t\t\theight: 500px;\r\n\t\t\tmargin: 0 auto;\r\n\t\t}\r\n\r\n\t\t#box3 img {\r\n\t\t\twidth: 100%;\r\n\t\t\theight: auto;\r\n\t\t}\r\n\r\n\t\t.left,\r\n\t\t.right {\r\n\t\t\tposition: absolute;\r\n\t\t\tdisplay: block;\r\n\t\t\tbackground: #000;\r\n\t\t\twidth: 500px;\r\n\t\t\theight: 500px;\r\n\t\t}\r\n&lt;\/style&gt;<\/pre>\n<pre class=\"lang:xhtml decode:true \" title=\"\u25bcHTML\" >&lt;div id=\"main\"&gt;\r\n\t\t&lt;div id=\"box1\" class=\"box\"&gt;\u30c6\u30ad\u30b9\u30c8\u3044\u3061\uff01&lt;\/div&gt;\r\n\t\t&lt;div id=\"box2\" class=\"box\"&gt;:)&lt;\/div&gt;\r\n\t\t&lt;div id=\"box3\" class=\"box\"&gt;&lt;img src=\"image\/topimg3.jpg\"&gt;&lt;\/div&gt;\r\n\t\t&lt;div id=\"box4\" class=\"box\"&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/slideattackbox2\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30b9\u30e9\u30a4\u30c9\u3059\u308b\u3068\u3001\u5185\u5bb9\u3092\u5de6\u53f3\u304b\u3089\u62bc\u3057\u3064\u3076\u3057\u3066\u3001\u6b21\u306e\u5185\u5bb9\u304c\u5de6\u53f3\u306e\u91cd\u308a\u3092\u306f\u3058\u304d\u8fd4\u3059\u3088\u3046\u306a\u30b9\u30e9\u30a4\u30c9\u3092jQuery\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30b9\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/521"}],"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=521"}],"version-history":[{"count":1,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/521\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/521\/revisions\/522"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}