I'm using HTML templates, which are based on Bootstrap 4.3.1. With the help of the Stack Overflow community, I managed to change the default behaviour of the accordions in these templates. Now only one panel can be opened at a time (i.e. as soon as a new panel is opened, the previously opened panel will automatically close). I also managed to change the background colour of the active panel by invoking aria attributes as follows:
.accordion .card .card-header button[aria-expanded="true"] {
background-color:#0965AC;
color: #ffffff;
}
A working example can be found on this CodePen (the aforementioned code can be found at the bottom of the CSS:
When I open a specific panel on page load using class="collapse show", the card-header of the open panel doesn't show the blue background. After closing and opening this panel again, the blue background shows.
Any suggestions on how I can, on page load, let the open panel also show the blue background?
I tried as follows, but no no avail:
.accordion .card .card-header button[class="collapse show"] {
background-color:#0965AC;
color: #ffffff;
}