Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Steve Davies
10,389 PointsMake my accordion title different colour on hover
I have this accordion, it is a bit like Frankensteins monster, I have copied and pasted it form everyone and put it together.
If you click on a section you will see that there are colour squeres. I would like the Accordion title to be background:green; when I float over it and for the next title background:pink; and so on.
Can you help?
3 Answers

bobkingstone
27,869 Pointsif this is static content I would simply add a class to each title label within the accordian with a hover value e.g.
<label for="ac-1" class="title1 hover-tag">COACHING & MENTORING STUDY</label>
<label for="ac-2" class="title hover-tag-2">RESEARCH & RESEARCH EVENTS</label>
.hover-tag:hover {
background-color: #9eab05;;
}
.hover-tag-2:hover {
background-color: #d10373;
}

Jeff Lemay
14,268 PointsThis is how you target the open accordion's label:
.accordion input:checked + label,
.accordion input:checked + label:hover {
background:green;
}
To target the specific ones so you can give each accordion its own color:
.accordion #ac-1:checked + label,
.accordion #ac-1:checked + label:hover {
background:green;
}
.accordion #ac-2:checked + label,
.accordion #ac-2:checked + label:hover {
background:pink;
}
By the way, this is a cool way to do accordions without needing js.

Steve Davies
10,389 PointsThank you for your help, it doesn't quite do what I want, the float over in the clsoed state still doesn't change colour when I hover.
Do please let me know if it is me!