I have set a function on the toggle button to transition the Bootstrap Icon Bars into an "X" shape on click. However, this does not seem to work. Any help is greatly appreciated. Pressing it result in nothing. Below is the CSS of just one bar for a simple example.
$(document).ready(function () {
$(".pro-toggle").on("click", function () {
$(".top-bar").toggleClass("active");
});
});
.pro-toggle .active .top-bar {
.pro-toggle.top-bar {
transform: rotate(0);
}
transform: rotate(45deg);
transform-origin: 10% 10%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="navbar-toggle collapsed pro-toggle pull-left" data-toggle="collapse">
<span class="icon-bar top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
</button>
Your
jQueryis toggling a class on the.top-barelement but it doesn't match with your CSS rule.Set the
.activeclass to the.top-barelement like thisCSS
LESS / SASS