Within my HTML templates, which are based on Bootstrap 4.3.1, I successfully altered the behavior of accordions thanks to support from the Stack Overflow community. Now, only one panel can be open at a time, automatically closing any previously opened panels when a new one is activated. To customize the active panel's appearance, I utilized aria attributes like so:
.accordion .card .card-header button[aria-expanded="true"] {
background-color:#0965AC;
color: #ffffff;
}
You can view a demonstration on this CodePen (the relevant code is located towards the end of the CSS).
However, upon loading the page with a specific panel set to initially display using class="collapse show"
, the card header of that panel does not reflect the blue background. Only after toggling the panel closed and then open again does the desired background appear.
Does anyone have suggestions on how I can ensure that the blue background is applied to the open panel upon page load?
I attempted the following without success:
.accordion .card .card-header button[class="collapse show"] {
background-color:#0965AC;
color: #ffffff;
}