{"id":5079,"date":"2023-09-04T23:50:36","date_gmt":"2023-09-04T14:50:36","guid":{"rendered":"http:\/\/www.lining-moon.casa\/andplus.co.jp\/?p=5079"},"modified":"2026-01-08T11:13:48","modified_gmt":"2026-01-08T02:13:48","slug":"post-5079","status":"publish","type":"post","link":"https:\/\/code-plus.jp\/gp\/post-5079\/","title":{"rendered":"JavaScript\u306b\u3088\u308b\u30bf\u30d6\u5207\u308a\u66ff\u3048\u6a5f\u80fd\u306e\u5b9f\u88c5\uff08invisibleTab.js\uff09"},"content":{"rendered":"<p>\u30a6\u30a7\u30d6\u30c7\u30b6\u30a4\u30f3\u306e\u4e2d\u3067\u3001\u30bf\u30d6\u5207\u308a\u66ff\u3048\u6a5f\u80fd\u306f\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u6574\u7406\u3057\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u3068\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3057\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306e\u52b9\u679c\u7684\u306a\u65b9\u6cd5\u3067\u3059\u3002\u4eca\u56de\u306f\u3001PC\u3067\u306e\u30bf\u30d6\u5207\u308a\u66ff\u3048\u3068\u30e2\u30d0\u30a4\u30eb\u3067\u306e\u30a2\u30f3\u30ab\u30fc\u30ea\u30f3\u30af\u6a5f\u80fd\u3092\u5099\u3048\u305f<code>invisibleTab.js<\/code>\u306e\u89e3\u8aac\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"language-javascript\"><code style=\"display: inline-block;\">(function () {\n\/\/invisibleTab:CSS\nvar insertStyle = document.createElement('style');\ninsertStyle.insertAdjacentHTML('beforeend', `@charset \"utf-8\";\n\/* \u30bf\u30d6\u30e1\u30cb\u30e5\u30fc\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u0f1a\u0f36\u22b0\u27e1\u22b1\u0f36\u0f1a\u0f3a *\/\n.tab-container {\n\tposition: relative;\n\tz-index: 10;\n\tdisplay: block;\n\twidth: 100%;\n\tmax-width: 100%;\n\theight: auto;\n\t\/* padding: \u4e0a  \u6a2a  \u4e0b *\/\n\tpadding: 1rem 0px 1rem;\n\toverflow: hidden;\n}\n\n.tab-container ul.menu {\n\twidth: 1000px;\n\tmax-width: 90vw;\n\theight: auto;\n\tmargin-right: auto;\n\tmargin-left: auto;\n}\n\n.tab-container ul.menu&gt;\n\nli {\n\twidth: 100%;\n\theight: auto;\n\ttext-align: center;\n\tmargin-bottom: 5px;\n}\n\n.tab-container ul.menu&gt;\nli&gt;\n\na {\n\twidth: 100%;\n\theight: auto;\n\tpadding: 0.2em 0px;\n\tfont-family: 'Cinzel', serif;\n\tborder: 1px solid #4F6874;\n}\n\n\/* \uff08PC\uff09 *\/\n@media print,\nscreen and (min-width: 768px) {\n\t.tab-container ul.menu {\n\t\t\/* Flex *\/\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t}\n\n\t.tab-container ul.menu&gt;\n\tli:not(:first-of-type)&gt;\n\n\ta {\n\t\tborder-left: none;\n\t}\n}\n\n.tab-container ul.menu&gt;\nli.current_tab_item&gt;\n\na {\n\tbackground: hsla(200, 33%, 92%, 1);\n\tfilter: brightness(1);\n}\n\n.tab-container ul.menu&gt;\nli&gt;\na:hover,\n.tab-container ul.menu&gt;\nli.current_tab_item&gt;\n\na {\n\tbackground: hsla(200, 33%, 92%, 1);\n\tfilter: brightness(1.03);\n}\n\n\/* \u5b50\u30da\u30fc\u30b8\uff1atabchpt-container\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u0f1a\u0f36\u22b0\u27e1\u22b1\u0f36\u0f1a\u0f3a *\/\n\/* \uff08PC\uff09 *\/\n@media print,\nscreen and (min-width: 768px) {\n\t.tabchpt-container {\n\t\theight: 0;\n\t\tvisibility: hidden;\n\t\topacity: 0;\n\t\toverflow: hidden;\n\t}\n\n\t.tabchpt-container.summon {\n\t\theight: auto;\n\t\tvisibility: visible;\n\t\topacity: 1;\n\t}\n}\n`);\ndocument.getElementsByTagName('head')[0].appendChild(insertStyle);\n})(); \/\/\/function invisibleTab:CSS();\n\n(function () {\n  \/\/invisibleTab:JS\n  let tabItems = Array.prototype.slice.call(document.querySelectorAll(\".tabs-item\"));\n  let tabChpts = Array.prototype.slice.call(document.querySelectorAll(\".tabchpt-container\"));\n  let tabLinks = Array.prototype.slice.call(document.querySelectorAll(\".tab-container .tabs-link\"));\n\n  function tabClickEvent(tabLink) {\n  tabLink.addEventListener('click', function (e) {\n      var thsParent = this.parentNode;\n      var tabChptId = this.getAttribute('href').substring(1); \/\/'#' \u3092\u53d6\u308a\u9664\u304f\n      var tabChpt = document.getElementById(tabChptId);\n      var tabItem = thsParent;\n\n      if (window.matchMedia('(min-width: 768px)').matches) {\n        e.preventDefault();\n      }\n      var thsParent = this.parentNode;\n      let hasCLASS = thsParent.classList.contains('current_tab_item');\n      if (hasCLASS) {\n        e.preventDefault();\n      } else {\n        \/\/\u95a2\u9023\u3059\u308b\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u3068\u30bf\u30d6\u30a2\u30a4\u30c6\u30e0\u3092\u9078\u629e\n        let targetTabChpt = document.querySelector(this.getAttribute('href'));\n        let targetTabItem = this.parentNode;\n\n        \/\/GSAP\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\n        const timeline = gsap.timeline();\n        timeline\n          .to(targetTabChpt, {\n            duration: 0.3,\n            opacity: 0,\n            onComplete: function () {\n              tabChpts.forEach(function (tabChpt) {\n                tabChpt.classList.remove('summon');\n              });\n              tabItems.forEach(function (tabItem) {\n                tabItem.classList.remove('current_tab_item');\n              });\n            }\n          })\n          .add(() =&amp; gt; {\n          targetTabChpt.classList.add('summon');\n          targetTabItem.classList.add('current_tab_item');\n        })\n      .to(targetTabChpt, {\n        duration: 0.3,\n        opacity: 1\n      }, \"&lt;0.3\"); \/\/'&lt;'\uff1a\u524d\u306e\u8981\u7d20\u304b\u3089*\u79d2\u5f8c\n\n    \/\/\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u518d\u751f\n    timeline.play();\n  }\n});\n} \/\/\/.Event('click')\ntabLinks.forEach((link) =&amp; gt; {\n  tabClickEvent(link);\n});\n}) (); \/\/\/function invisibleTab:JS();\n<\/code><\/pre>\n<p><\/p>\n<h3>\u30b3\u30fc\u30c9\u306e\u6982\u8981<\/h3>\n<p>invisibleTab.js\u306f\u4e3b\u306b2\u3064\u306e\u90e8\u5206\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059:<\/p>\n<p><b class=\"fw-600\">CSS\u306e\u633f\u5165: <\/b>\u30bf\u30d6\u3068\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<br \/>\n<b class=\"fw-600\">JavaScript\u6a5f\u80fd: <\/b>\u30bf\u30d6\u306e\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u51e6\u7406\u3057\u3001\u95a2\u9023\u3059\u308b\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u8868\u793a\u3068\u975e\u8868\u793a\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002<\/p>\n<h4>1. CSS\u306e\u633f\u5165 (invisibleTab:CSS)<\/h4>\n<p>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u65b0\u3057\u3044\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u3092\u52d5\u7684\u306b\u30a6\u30a7\u30d6\u30da\u30fc\u30b8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u306f\u30bf\u30d6\u30b3\u30f3\u30c6\u30ca\u3068\u30bf\u30d6\u30a2\u30a4\u30c6\u30e0\u306e\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3092\u5b9a\u7fa9\u3057\u3001768px\u4ee5\u4e0a\u306e\u753b\u9762\u5e45\u3067\u7570\u306a\u308b\u30b9\u30bf\u30a4\u30eb\u3092\u9069\u7528\u3057\u307e\u3059\u3002<\/p>\n<p><\/p>\n<h4>\u30b3\u30fc\u30c9\u306e\u8a73\u7d30:<\/h4>\n<p><b class=\"fw-600\">.tab-container: <\/b>\u30bf\u30d6\u30b3\u30f3\u30c6\u30ca\u306e\u57fa\u672c\u7684\u306a\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<br \/>\n<b class=\"fw-600\">@media print, screen and (min-width: 768px): <\/b>768px\u4ee5\u4e0a\u306e\u753b\u9762\u5e45\u3067\u9069\u7528\u3055\u308c\u308b\u30b9\u30bf\u30a4\u30eb\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u4e3b\u306b\u30d5\u30ec\u30c3\u30af\u30b9\u30dc\u30c3\u30af\u30b9\u3092\u4f7f\u7528\u3057\u3066\u30bf\u30d6\u30a2\u30a4\u30c6\u30e0\u3092\u884c\u65b9\u5411\u306b\u914d\u7f6e\u3057\u307e\u3059\u3002<br \/>\n<b class=\"fw-600\">.tabchpt-container: <\/b>\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002PC\u30d3\u30e5\u30fc\u3067\u306f\u3001\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u975e\u8868\u793a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><\/p>\n<h4>2. JavaScript\u6a5f\u80fd (invisibleTab:JS)<\/h4>\n<p>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30bf\u30d6\u306e\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u51e6\u7406\u3057\u307e\u3059\u3002\u5404\u30bf\u30d6\u30ea\u30f3\u30af\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u308b\u3068\u3001\u95a2\u9023\u3059\u308b\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u8868\u793a\u3055\u308c\u3001\u4ed6\u306e\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u975e\u8868\u793a\u306b\u306a\u308a\u307e\u3059\u3002GSAP\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3001\u30bf\u30d6\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u8868\u793a\u3068\u975e\u8868\u793a\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002<\/p>\n<h5>\u30b3\u30fc\u30c9\u306e\u8a73\u7d30:<\/h5>\n<p><\/p>\n<p><b class=\"fw-600\">tabClickEvent: <\/b>\u30bf\u30d6\u30ea\u30f3\u30af\u306e\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u51e6\u7406\u3059\u308b\u95a2\u6570\u3067\u3059\u3002\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u30bf\u30d6\u30ea\u30f3\u30af\u306e\u89aa\u8981\u7d20\u304ccurrent_tab_item\u30af\u30e9\u30b9\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\uff08\u3059\u306a\u308f\u3061\u3001\u73fe\u5728\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u5834\u5408\uff09\u3001e.preventDefault();\u3092\u547c\u3073\u51fa\u3057\u3066\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u52d5\u4f5c\u3092\u30ad\u30e3\u30f3\u30bb\u30eb\u3057\u307e\u3059\u3002\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u3001\u30bf\u30d6\u306e\u5207\u308a\u66ff\u3048\u3068\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u304c\u884c\u308f\u308c\u307e\u3059\u3002<\/p>\n<p><\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>invisibleTab.js\u306f\u3001PC\u3068\u30e2\u30d0\u30a4\u30eb\u306e\u4e21\u65b9\u3067\u52b9\u679c\u7684\u306a\u30bf\u30d6\u5207\u308a\u66ff\u3048\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002CSS\u90e8\u5206\u306f\u30bf\u30d6\u306e\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3092\u7ba1\u7406\u3057\u3001JavaScript\u90e8\u5206\u306f\u30bf\u30d6\u306e\u52d5\u7684\u306a\u52d5\u4f5c\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u30a6\u30a7\u30d6\u30da\u30fc\u30b8\u306b\u6574\u7406\u3055\u308c\u305f\u30bf\u30d6\u5207\u308a\u66ff\u3048\u6a5f\u80fd\u3092\u8fc5\u901f\u306b\u8ffd\u52a0\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>","protected":false},"excerpt":{"rendered":"\u30a6\u30a7\u30d6\u30c7\u30b6\u30a4\u30f3\u306e\u4e2d\u3067\u3001\u30bf\u30d6\u5207\u308a\u66ff\u3048\u6a5f\u80fd\u306f\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u6574\u7406\u3057\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u3068\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3057\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306e\u52b9\u679c\u7684\u306a\u65b9\u6cd5\u3067\u3059\u3002\u4eca\u56de\u306f\u3001PC\u3067\u306e\u30bf\u30d6\u5207\u308a\u66ff\u3048\u3068\u30e2\u30d0\u30a4\u30eb\u3067\u306e\u30a2\u30f3\u30ab\u30fc\u30ea\u30f3\u30af\u6a5f\u80fd\u3092\u5099\u3048\u305finvisibleTab.js\u306e[...]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":""},"categories":[12],"tags":[],"group":[],"class_list":["post-5079","post","type-post","status-publish","format-standard","category-javascript"],"acf":[],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/5079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/comments?post=5079"}],"version-history":[{"count":0,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/5079\/revisions"}],"wp:attachment":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media?parent=5079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/categories?post=5079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/tags?post=5079"},{"taxonomy":"group","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/group?post=5079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}