I don’t see how this can be done without Javascript. The closest is to using the :active
but that only works the moment the mouse is pressed:
.collapse {
height: 0px;
overflow: hidden;
transition: height 0.8s;
}
h4:active + .collapse {
height: 200px;
}
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<h4><a href="#col3Content" data-toggle="collapse">Faz um clique longo...</a></h4>
<div id="col3Content" class="collapse">Bacon ipsum dolor amet pancetta fatback ground round, bresaola strip steak boudin filet mignon turkey kevin drumstick sirloin swine pork belly. Corned beef shankle ham hock drumstick capicola short loin ball tip tri-tip kevin turkey chuck pork belly venison bacon. Fatback turkey swine tongue, chuck jerky doner pork belly pork corned beef rump leberkas. Ham hock fatback bresaola tri-tip salami.</div>
</div>
To do this without Javascript you can use the trick of checkbox
, which basically uses the logic of adjacent sibling
in the CSS I mentioned above but using the state of the checkbox
as a switch:
label input[type="checkbox"] {
display: none;
}
label h4 {
cursor: pointer;
text-decoration: underline;
}
.collapse {
height: 0px;
overflow: hidden;
transition: height 0.8s;
}
input:checked + .collapse {
height: 200px;
}
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<label>
<h4>Clica aqui</h4>
<input type="checkbox" />
<div id="col3Content" class="collapse">Bacon ipsum dolor amet pancetta fatback ground round, bresaola strip steak boudin filet mignon turkey kevin drumstick sirloin swine pork belly. Corned beef shankle ham hock drumstick capicola short loin ball tip tri-tip kevin turkey chuck pork
belly venison bacon. Fatback turkey swine tongue, chuck jerky doner pork belly pork corned beef rump leberkas. Ham hock fatback bresaola tri-tip salami.</div>
</label>
</div>
There is also a new HTML5 technology that does this, without Javascript and without CSS, using the elements <details>
and <summary>
:
<details>
<summary>Clica aqui...</summary>
<div id="col3Content" class="collapse">Bacon ipsum dolor amet pancetta fatback ground round, bresaola strip steak boudin filet mignon turkey kevin drumstick sirloin swine pork belly. Corned beef shankle ham hock drumstick capicola short loin ball tip tri-tip kevin turkey chuck pork belly
venison bacon. Fatback turkey swine tongue, chuck jerky doner pork belly pork corned beef rump leberkas. Ham hock fatback bresaola tri-tip salami.</div>
</details>
You know Bootstrap has the right Javascript?
– Sergio
Yes but in the video it is possible to make Text Ripper and expand with only these code
– user66123
I think I already answered one that does this, show the expanded text by clicking (the solution is checkbox if it is one item, and radiobutton if there are several, but to show one at a time). While I can’t find the link, there is another variant: http://answall.com/questions/99108/como-clicar-e-descer-uma-parte-oculta
– Bacco