TL;DR: Modify CSS :before, to previous sub divs
I'm currently working with a CMS, trying to modify some of the CSS. I can't change the HTML to make this easier, so I have to rework the CSS
I'm copying a rating system code from https://codeconvey.com.
The HTML for the input for the code sample is along the lines of:
<div class="form-group">
<input ...>
<label ...>
<input ...>
<label ..>
</div>
While the HTML I have to work with is:
<div class="form-group">
<div class="form-check">
<input ...>
<label ...>
</div>
<div class="form-check">
<input ...>
<label ...>
</div>
</div>
Where I'm stuck is the code sample uses :before, and :hover to highlight the previous stars. I need assistance in how to change the CSS to have the same affect over divs. Here's the code I have
.form-group {
display: inline-block;
}
.form-group * {
font-size: 3rem;
}
.form-group .form-check > input {
display: none;
}
.form-group .form-check > input + label {
/* only enough room for the star */
display: inline-block;
overflow: hidden;
text-indent: 9999px;
width: 1em;
white-space: nowrap;
cursor: pointer;
}
.form-group .form-check > input + label:before {
display: inline-block;
text-indent: -9999px;
content: "☆";
color: #888;
}
.form-group .form-check > input:checked ~ label:before, .form-group > div + label:hover ~ label:before, .form-group > div + label:hover:before {
content: "★";
color: #78c494;
text-shadow: 0 0 1px #333;
}
.form-group .form-check > #form-check-57217rate5 + label {
text-indent: -9999px;
width: .5em;
margin-left: -.5em;
}
.form-group .form-check > #form-check-57217rate5 + label:before {
width: .5em;
}
.form-group :hover .form-check > input + label:before {
content: "☆";
color: #888;
text-shadow: none;
}
.form-group :hover .form-check > input + label:hover ~ label:before, .form-group :hover > input + label:hover:before {
content: "★";
color: #78c494;
text-shadow: 0 0 1px #333;
}
the form-check-57217 is the last radio button, value 0