Skip to content

Is there a way we can distinguish parent accordions from nested accordions in css without using ids? #1107

Answered by gadenbuie
Shelmith-Kariuki asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the CSS selector .accordion .accordion to target an accordion nested within another accordion. So you can use rules like this to get the appearance you'd like:

/* Nested accordions */

/* Indent titles of nested accordions */
.accordion .accordion .accordion-button {
  padding-inline-start: 2rem;
}

/* Accordions should have a maroon background with white text when collapsed*/
.accordion .accordion .accordion-button.collapsed {
  color: white;
  background-color: maroon;
}

/* Accordions should have white background with maroon text when not collapsed*/
.accordion .accordion .accordion-button:not(.collapsed) {
  color: maroon;
  background-color: white;
}

Also, you can use som…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Shelmith-Kariuki
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants