I’m using a pure CSS collapsible environment from this link: https://www.digitalocean.com/community/tutorials/css-collapsible. It worked great for years, but suddenly all of my collapsible elements are un-collapsed by default and they include a visible checkbox, which didn’t used to be the case.
Here’s an example of the HTML:
<div class="wrap-collapsible">
<input id="eg1" class="toggle" type="checkbox">
<label for="eg2" class="lbl-toggle">First label</label>
<div class="collapsible-content">
<div class="content-inner">
<p>Initial content</p>
</div>
</div>
<input id="eg2" class="toggle" type="checkbox">
<label for="eg2" class="lbl-toggle">Fancy label</label>
<div class="collapsible-content">
<div class="content-inner">
<p>Some content</p>
<p>More content</p>
</div>
</div>
</div>
And here’s the CSS:
.wrap-collapsible {
margin-bottom: 1.2rem 0;
}
input[type='checkbox'] {
display: none;
}
.lbl-toggle {
/*display: block;
font-size: 8ppx;*/
text-align: left;
padding: -10px;
/*color: black;*/
background: white;
cursor: pointer;
border-radius: 7px;
transition: all 0.25s ease-out;
}
.lbl-toggle:hover {
color: grey;
}
.lbl-toggle::before {
content: ' ';
display: inline-block;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-left: 5px solid currentColor;
vertical-align: middle;
margin-right: .7rem;
transform: translateY(-2px);
transition: transform .2s ease-out;
}
.collapsible-content .content-inner {
/*background: rgba(250, 224, 66, .2);
border-bottom: 1px solid rgba(250, 224, 66, .45);*/
border-bottom-left-radius: 7px;
border-bottom-right-radius: 7px;
padding: 0rem 0rem 0rem 2rem;
}
.collapsible-content {
max-height: 0px;
overflow: hidden;
transition: max-height .25s ease-in-out;
}
.toggle:checked + .lbl-toggle + .collapsible-content {
max-height: 350px;
}
.toggle:checked + .lbl-toggle::before {
transform: rotate(90deg) translateX(-3px);
}
.toggle:checked + .lbl-toggle {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
I don’t know a ton of CSS or HTML, so I haven’t tried anything to fix it.
Daniel Gold Danny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.