Last active
July 24, 2021 12:10
-
-
Save absent1706/6ebcee9f2d7992e26f073905fc28ca97 to your computer and use it in GitHub Desktop.
Bootstrap-collapse rotate icon. https://jsfiddle.net/1L3xy40k/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<style> | |
[data-toggle="collapse"][aria-expanded="true"] > .js-rotate-if-collapsed | |
{ | |
-webkit-transform: rotate(180deg); | |
-moz-transform: rotate(180deg); | |
-ms-transform: rotate(180deg); | |
-o-transform: rotate(180deg); | |
transform: rotate(180deg); | |
} | |
</style> | |
</head> | |
<body> | |
<h3>Initially closed</h3> | |
<div style="cursor: pointer" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false"> | |
Header | |
<span class="glyphicon glyphicon-menu-down js-rotate-if-collapsed"></span> | |
</div> | |
<div id="collapseExample" class="collapse"> | |
Body | |
</div> | |
<hr> | |
<h3>Initially opened</h3> | |
<div style="cursor: pointer" data-toggle="collapse" data-target="#collapseExample2" aria-expanded="true"> | |
Header | |
<span class="glyphicon glyphicon-menu-down js-rotate-if-collapsed"></span> | |
</div> | |
<div id="collapseExample2" class="collapse in"> | |
Body | |
</div> | |
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
</body> | |
</html> |
"using multiple collapse sections and when (with custom js/jquery) I clicked on section's icon all the other sections would flip state as well"
Hey I am having trouble with this exact problem.... but its actually with this solution... How did you solve it? I can't get just one of the sections to collapse. Here is my fiddle... https://jsfiddle.net/vaughnick/f4gkxx4n/
Thanks for any help you can provide.
Thanks, its work
Thanks, works like a charm
Thanks, worked really fine!
This is awesome, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one was the best solution out of many that I searched for and just with a CCS rule and the existing BS.js....thanks!!!! I found it especially annoying problem since I was using multiple collapse sections and when (with custom js/jquery) I clicked on section's icon all the other sections would flip state as well. This solution allows for discrete behavior of each icon. Cheers!