One thing I realized and am not sure how to address (sorry, this is going to be a long reply)…
Since you want the check boxes to be to the right of the labels and are using a flexbox (and I’m assuming eventually a responsive design for mobile/small screens)…
The problem of check box alignment is going to pop up again. It looks good and aligned at a certain veiwport size. But as soon as it flexes/wraps, the boxes will push the labels down a line to accommodate the wrapping. So it re-introduces the label/checkbox alignment issue.
The “standard” way people implement check boxes is checkbox to the left, label to the right.
There might be a way to have the check boxes on the right, have it flex properly and retain alignment, but I personally would not know how to accomplish that. Maybe others on here could help you with that issue, or you could just put the check boxes on the left as most sites do.
(I’ve seen several tutorials dealing with how to keep the alignment with labels and check boxes when using flex, but the boxes are all on the left and labels to the right in the tutorials and examples.
You can also wrap the input with the label tag so that the label becomes the container for the input…
And if you do switch to checkbox on left, label on right, the code would look like this:
<label>
<input type="checkbox" id="checkbox_id" name="checkbox_name" class="checkbox_class">
Label Here</label>
Doing something like this:
<label>Label Here
<input type="checkbox" id="animals" name="interest" class="interest_inputs">
</label>
Would put the label back on the left and recreate the alignment issue you’d be trying to avoid.
For the flex issues, you can wrap each label/input pair in divs like this:
<div class = "some_class_name">
<label for="animals" class="interest-label">Animals
<input type="checkbox" id="animals" name="interest" class="interest-input">
</label>
</div>
<div class = "some_class_name">
<label for="animals" class="interest-label">Anime
<input type="checkbox" id="anime" name="interest" class="interest-input">
</label>
</div>
I hope all that made sense. This info is from doing some research and reading a few topics about flex and checkbox alignment in fcc Forums
Need help with elements positioning
How display:flex did not effect the arrangement of labels in form of the given sample in Survey Form Project Challenge
(@lasjorg is a very knowledgeable mod and I think codes content for FCC, so I trust their reply in that post)
If you look at the FCC Survey Form code in Developer Tools Inspector tool, you see that all the labels for checkboxes are flex.
FCC Survey Form
Sorry, I thought it was important to point these things out, as I do not want to lead you astray. Feel free to double check and verify what I am saying. As I said in an earlier reply, I’m not an expert or coder, just a fellow student.
I don’t want to give you wrong info. If anyone else reading this knows a better way to handle these issues, please DO chime in!
Happy Coding!