Is there a way to change the opacity of certain images inside my div when hovering over them? Specifically, I want the 4th image and the first three to have an opacity value of 1. I've looked into using nth-child but am unsure how to implement it for hovering effects. Additionally, is it possible to click on the 4th image and have all four images (except the last one) maintain an opacity of 1?
<div class="rating" style="width:75px;">
<span>
<img class="plus" src="http://icons.iconarchive.com/icons/designcontest/casino/96/Chip-1-icon.png" width="16" height="16" />
</span>
<span>
<img class="plus" src="http://icons.iconarchive.com/icons/designcontest/casino/96/Chip-1-icon.png" width="16" height="16" />\
</span>
<span>
<img class="plus" src="http://icons.iconarchive.com/icons/designcontest/casino/96/Chip-1-icon.png" width="16" height="16" />
</span>
<span>
<img class="plus" src="http://icons.iconarchive.com/icons/designcontest/casino/96/Chip-1-icon.png" width="16" height="16" />
</span>
<span>
<img class="plus" src="http://icons.iconarchive.com/icons/designcontest/casino/96/Chip-1-icon.png" width="16" height="16" />
</span>
</div>
If you need further clarification or additional information, please feel free to ask!
CSS:
.rating span img {
opacity:0.5;
}
.rating:hover span img {
opacity:1;
}
.rating:hover span:hover ~ span img {
opacity:0.5
}
.rating {
unicode-bidi: bidi-override;
direction: rtl;
}
.plus {
opacity:0.5;
}
.plus:hover {
opacity:1;
}
.rating > span {
display: inline-block;
position: relative;
width: 1.1em;
padding:1px;
}
.rating > span:hover:before,
.rating > span:hover ~ span:before {
position: absolute;
}