{"id":8329,"date":"2016-06-15T11:47:42","date_gmt":"2016-06-15T10:47:42","guid":{"rendered":"http:\/\/www.wjst.de\/blog\/?p=8329"},"modified":"2016-06-15T13:55:29","modified_gmt":"2016-06-15T12:55:29","slug":"how-to-switch-divs-on-or-off-a-super-neat-trick","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2016\/06\/how-to-switch-divs-on-or-off-a-super-neat-trick\/","title":{"rendered":"How to switch divs on or off &#8211; a super neat trick"},"content":{"rendered":"<p>I want to\u00a0hide a div container as it\u00a0clutters my otherwise clean picture display. And I found some javascript &#8211; free, CSS only solution: the\u00a0 <a href=\"https:\/\/css-tricks.com\/the-checkbox-hack\/\">checkbox hack<\/a>. Modified it a bit while it looks now like this<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;label for=&quot;t&quot;&gt;license me...&lt;\/label&gt;\r\n&lt;input id=&quot;t&quot; type=&quot;checkbox&quot; \/&gt;\r\n&lt;div id=&quot;buy&quot;&gt;price&lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\ninput&#x5B;type=checkbox] {position: absolute;\r\n top: -9999px; left: -9999px; }\r\nlabel { border:none; cursor: pointer; }\r\nlabel:hover { border-bottom:1px solid #444; }\r\ndiv#buy { display:none; }\r\ninput&#x5B;type=checkbox]:checked ~ div#buy\r\n { display: block; }\r\n<\/pre>\n<p>You get the idea: whenever the label of the unvisible checkbox is being clicked, the display state of the div container is changing between on to off.<\/p>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 12.04.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>I want to\u00a0hide a div container as it\u00a0clutters my otherwise clean picture display. And I found some javascript &#8211; free, CSS only solution: the\u00a0 checkbox hack. Modified it a bit while it looks now like this &lt;label for=&quot;t&quot;&gt;license me&#8230;&lt;\/label&gt; &lt;input id=&quot;t&quot; type=&quot;checkbox&quot; \/&gt; &lt;div id=&quot;buy&quot;&gt;price&lt;\/div&gt; input&#x5B;type=checkbox] {position: absolute; top: -9999px; left: -9999px; } label { &hellip; <a href=\"https:\/\/www.wjst.de\/blog\/sciencesurf\/2016\/06\/how-to-switch-divs-on-or-off-a-super-neat-trick\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to switch divs on or off &#8211; a super neat trick<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2822,2986,2771],"class_list":["post-8329","post","type-post","status-publish","format-standard","hentry","category-computer-software","tag-css","tag-hide-block","tag-javascript"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/8329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/comments?post=8329"}],"version-history":[{"count":12,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/8329\/revisions"}],"predecessor-version":[{"id":8341,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/8329\/revisions\/8341"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=8329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=8329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=8329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}