{"id":1144,"date":"2023-04-02T14:51:00","date_gmt":"2023-04-02T11:51:00","guid":{"rendered":"https:\/\/notes.profidev.online\/?p=1144"},"modified":"2023-04-02T09:01:44","modified_gmt":"2023-04-02T06:01:44","slug":"pure-css-accordion","status":"publish","type":"post","link":"https:\/\/notes.profidev.online\/ru\/accordion\/1144\/","title":{"rendered":"Pure CSS Accordion"},"content":{"rendered":"<figure class=\"wp-block-video\"><video height=\"481\" style=\"aspect-ratio: 941 \/ 481;\" width=\"941\" controls src=\"https:\/\/notes.profidev.online\/wp-content\/uploads\/2023\/04\/vokoscreenng-2023-04-02_07-50-54.webm\"><\/video><\/figure>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">  &lt;h1&gt;Pure CSS Accordion &lt;sup&gt;2.0&lt;\/sup&gt;&lt;\/h1&gt;\n  &lt;div class=&quot;row&quot;&gt;\n    &lt;div class=&quot;col&quot;&gt;\n      &lt;h2&gt;Open &lt;b&gt;multiple&lt;\/b&gt;&lt;\/h2&gt;\n      &lt;div class=&quot;tabs&quot;&gt;\n        &lt;div class=&quot;tab&quot;&gt;\n          &lt;input type=&quot;checkbox&quot; id=&quot;chck1&quot;&gt;\n          &lt;label class=&quot;tab-label&quot; for=&quot;chck1&quot;&gt;Item 1&lt;\/label&gt;\n          &lt;div class=&quot;tab-content&quot;&gt;\n            Lorem ipsum dolor sit amet consectetur, adipisicing elit. Ipsum, reiciendis!\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;tab&quot;&gt;\n          &lt;input type=&quot;checkbox&quot; id=&quot;chck2&quot;&gt;\n          &lt;label class=&quot;tab-label&quot; for=&quot;chck2&quot;&gt;Item 2&lt;\/label&gt;\n          &lt;div class=&quot;tab-content&quot;&gt;\n            Lorem ipsum dolor sit amet consectetur adipisicing elit. A, in!\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n    &lt;div class=&quot;col&quot;&gt;\n      &lt;h2&gt;Open &lt;b&gt;one&lt;\/b&gt;&lt;\/h2&gt;\n      &lt;div class=&quot;tabs&quot;&gt;\n        &lt;div class=&quot;tab&quot;&gt;\n          &lt;input type=&quot;radio&quot; id=&quot;rd1&quot; name=&quot;rd&quot;&gt;\n          &lt;label class=&quot;tab-label&quot; for=&quot;rd1&quot;&gt;Item 1&lt;\/label&gt;\n          &lt;div class=&quot;tab-content&quot;&gt;\n            Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eos, facilis.\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;tab&quot;&gt;\n          &lt;input type=&quot;radio&quot; id=&quot;rd2&quot; name=&quot;rd&quot;&gt;\n          &lt;label class=&quot;tab-label&quot; for=&quot;rd2&quot;&gt;Item 2&lt;\/label&gt;\n          &lt;div class=&quot;tab-content&quot;&gt;\n            Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nihil, aut.\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n        &lt;div class=&quot;tab&quot;&gt;\n          &lt;input type=&quot;radio&quot; id=&quot;rd3&quot; name=&quot;rd&quot;&gt;\n          &lt;label for=&quot;rd3&quot; class=&quot;tab-close&quot;&gt;Close &amp;times;&lt;\/label&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;css&quot;,&quot;mime&quot;:&quot;text\/css&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;CSS&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;css&quot;}\">@charset &quot;UTF-8&quot;;\nbody {\n  color: #2c3e50;\n  background: #ecf0f1;\n  padding: 0 1em 1em;\n}\n\nh1 {\n  margin: 0;\n  line-height: 2;\n  text-align: center;\n}\n\nh2 {\n  margin: 0 0 0.5em;\n  font-weight: normal;\n}\n\ninput {\n  position: absolute;\n  opacity: 0;\n  z-index: -1;\n}\n\n.row {\n  display: flex;\n}\n.row .col {\n  flex: 1;\n}\n.row .col:last-child {\n  margin-left: 1em;\n}\n\n\/* Accordion styles *\/\n.tabs {\n  border-radius: 8px;\n  overflow: hidden;\n  box-shadow: 0 4px 4px -2px rgba(0, 0, 0, 0.5);\n}\n\n.tab {\n  width: 100%;\n  color: white;\n  overflow: hidden;\n}\n.tab-label {\n  display: flex;\n  justify-content: space-between;\n  padding: 1em;\n  background: #2c3e50;\n  font-weight: bold;\n  cursor: pointer;\n  \/* Icon *\/\n}\n.tab-label:hover {\n  background: #1a252f;\n}\n.tab-label::after {\n  content: &quot;\u276f&quot;;\n  width: 1em;\n  height: 1em;\n  text-align: center;\n  transition: all 0.35s;\n}\n.tab-content {\n  max-height: 0;\n  padding: 0 1em;\n  color: #2c3e50;\n  background: white;\n  transition: all 0.35s;\n}\n.tab-close {\n  display: flex;\n  justify-content: flex-end;\n  padding: 1em;\n  font-size: 0.75em;\n  background: #2c3e50;\n  cursor: pointer;\n}\n.tab-close:hover {\n  background: #1a252f;\n}\n\ninput:checked + .tab-label {\n  background: #1a252f;\n}\ninput:checked + .tab-label::after {\n  transform: rotate(90deg);\n}\ninput:checked ~ .tab-content {\n  max-height: 100vh;\n  padding: 1em;\n}<\/pre><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1146,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[16],"class_list":["post-1144","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-accordion","tag-htmlcss"],"_links":{"self":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/comments?post=1144"}],"version-history":[{"count":1,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1144\/revisions"}],"predecessor-version":[{"id":1147,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1144\/revisions\/1147"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media\/1146"}],"wp:attachment":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media?parent=1144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/categories?post=1144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/tags?post=1144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}