CSS How would I get these checkboxes into a grid layout - html

I want to set these checkboxes up in a table style grid without using a table in HTML. I was trying CSS but it seems like I will need to add a class to each tag for each slot.
Is there a way I can avoid this?
<div class = permissions_grid>
<div class="column_labels"></div>
<label>All Members</label>
<label>Relevant Experience</label>
<label>HUB Moderators</label>
<label>Invited Members</label>
</div>
<div class="row_edit_documents">
<label>Edit Documents</label>
<input type="checkbox" class="all-D" name="edit_docs" value="all">
<input type="checkbox" class="relevant" name="edit_docs" value="relevant">
<input type="checkbox" class="moderators" name="edit_docs" value="moderators">
<input type="checkbox" class="invited" name="edit_docs" value="invited" checked>
</div>
<div class = "row_add_categories">
<label>Add Feedback Categories</label>
<input type="checkbox" class="all-C" name="add_cat" value="all" checked>
<input type="checkbox" class="relevant" name="add_cat" value="relevant">
<input type="checkbox" class="moderators" name="add_cat" value="moderators">
<input type="checkbox" class="invited" name="add_cat" value="invited">
</div>
<div class = "row_move_com_cat">
<label>Move Comments and Categories</label>
<span class="x">X</span>
<input type="checkbox" class="relevant" name="move" value="relevant">
<input type="checkbox" class="moderators" name="move" value="moderators" checked>
<input type="checkbox" class="invited" name="move" value="invited" checked>
</div>
</div>
The first row starts at position 2 which I think I can easily mark in CSS. But How do I make sure all of the inputs and labels are even spaced?
Thank you
Kevin

You can use flexbox to get the result you want.
You are probably having some issues to do an error in your HTML.
In the top of your html you close a div tag early.
<div class="column_labels"></div> <!-- EXTRA CLOSING DIV TAG HERE -->
<label>All Members</label>
<label>Relevant Experience</label>
<label>HUB Moderators</label>
<label>Invited Members</label>
</div>
.permissions_grid {
display: flex;
flex-flow: column nowrap;
}
.permissions_grid > div {
display: flex;
flex-flow: row nowrap;
flex-basis: 20%;
text-align: center;
}
.permissions_grid > div > * {
flex: 1;
}
<div class=permissions_grid>
<div>
<label></label>
<label>All Members</label>
<label>Relevant Experience</label>
<label>HUB Moderators</label>
<label>Invited Members</label>
</div>
<div>
<label>Edit Documents</label>
<input type="checkbox" class="all-D" name="edit_docs" value="all">
<input type="checkbox" class="relevant" name="edit_docs" value="relevant">
<input type="checkbox" class="moderators" name="edit_docs" value="moderators">
<input type="checkbox" class="invited" name="edit_docs" value="invited" checked>
</div>
<div>
<label>Add Feedback Categories</label>
<input type="checkbox" class="all-C" name="add_cat" value="all" checked>
<input type="checkbox" class="relevant" name="add_cat" value="relevant">
<input type="checkbox" class="moderators" name="add_cat" value="moderators">
<input type="checkbox" class="invited" name="add_cat" value="invited">
</div>
<div>
<label>Move Comments and Categories</label>
<span class="x">X</span>
<input type="checkbox" class="relevant" name="move" value="relevant">
<input type="checkbox" class="moderators" name="move" value="moderators" checked>
<input type="checkbox" class="invited" name="move" value="invited" checked>
</div>
</div>

Related

How do I align multiple check boxes with their own texts on the same row?

I made a form with some check boxes and the check boxes with their texts are displayed inline:
enter image description here
What I'm trying to do is to display one checkbox with it's text per row so I tried creating a class for all the check boxes and within the CSS, added display: block:
.checkbox {
display: block;
}
From what I've read, it's better to avoid using br tags all the time in your HTML and attempt to do your styling as much as you can within your CSS.
However, this is what happens:
enter image description here
When trying to search online for this issue, I just get results on how to align multiple check boxes/ fields into the same row.
Here is the HTML:
<p>What would you like to see improved? (Check all that apply)</p>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="frontEnd" value="frontEnd">Front-end Projects</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="backEnd" value="backEnd">Back-end Projects</input>
<input type="checkbox" class="checkbox" id="dataVisualization" value="frontEnd">Data Visualization</input>
<input type="checkbox" class="checkbox" id="challengesImproved" value="challengesImproved">Challenges</input>
<input type="checkbox" class="checkbox" id="openSourceCommunity" value="openSourceCommunity">Open Source Community</input>
<input type="checkbox" class="checkbox" id="gitterHelpRooms" value="gitterHelpRooms">Gitter help rooms</input>
<input type="checkbox" class="checkbox" id="videos" value="videos">Videos</input>
<input type="checkbox" class="checkbox" id="cityMeetups" value="cityMeetups">City Meetups</input>
<input type="checkbox" class="checkbox" id="wiki" value="wiki">Wiki</input>
<input type="checkbox" class="checkbox" id="forum" value="forum">Forum</input>
<input type="checkbox" class="checkbox" id="additionalCourses" value="additionalCourses">Additional Courses</input>
Something like this could work, but there other ways
label {
display: block;
}
<label>
<input type="checkbox" name="" id="">
Ola3
</label>
<label>
<input type="checkbox" name="" id="">
Ola1
</label>
<label>
<input type="checkbox" name="" id="">
Ola2
</label>
Put your <input type="checkbox"> and <label> for that checkbox in a <div>.
<div>
<input type="checkbox" id="first">
<label for="first">First</label>
</div>
<div>
<input type="checkbox" id="second">
<label for="second">Second</label>
</div>
This way you don't need to style you container because <div> has display: block by default.
Edit: mistake on my end pointed out in comments. Added id to inputs.
Method -1 - using a display:block;
label {display:block;}
<p>What would you like to see improved? (Check all that apply)</p>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="frontEnd" value="frontEnd">Front-end Projects</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="backEnd" value="backEnd">Back-end Projects</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="dataVisualization" value="frontEnd">Data Visualization</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="challengesImproved" value="challengesImproved">Challenges</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="openSourceCommunity" value="openSourceCommunity">Open Source Community</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="gitterHelpRooms" value="gitterHelpRooms">Gitter help rooms</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="videos" value="videos">Videos</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="cityMeetups" value="cityMeetups">City Meetups</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="wiki" value="wiki">Wiki</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="forum" value="forum">Forum</input>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="additionalCourses" value="additionalCourses">Additional Courses</input>
Method -2 : using a <br>
<p>What would you like to see improved? (Check all that apply)</p>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="frontEnd" value="frontEnd">Front-end Projects</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="backEnd" value="backEnd">Back-end Projects</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="dataVisualization" value="frontEnd">Data Visualization</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="challengesImproved" value="challengesImproved">Challenges</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="openSourceCommunity" value="openSourceCommunity">Open Source Community</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="gitterHelpRooms" value="gitterHelpRooms">Gitter help rooms</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="videos" value="videos">Videos</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="cityMeetups" value="cityMeetups">City Meetups</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="wiki" value="wiki">Wiki</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="forum" value="forum">Forum</input>
<br>
<label for="frontEnd">
<input type="checkbox" class="checkbox" id="additionalCourses" value="additionalCourses">Additional Courses</input>

How to align the checkbox/radio button elements?

I am creating a survey form just for a project on FCC.
I tried putting the <input> tag inside <label>, also used <fieldset> but nothing worked.
<p id="purpose">
<label for="business"><input id="business" type="radio" name="purpose" value="business" checked> business</label>
<label for="leisure"><input type="radio" id="leisure" name="purpose" value="leisure">Leisure</label>
<label for="passingby"><input type="radio" id="passingby" name="purpose" value="passingby">Passing by</label>
<label for="others"><input type="radio" id="others" name="purpose" value="others">others</label>
</p>
<p class="improve">What do we need to improve?</p>
<label for="food"><input type="checkbox" id="food" name="food">Food</label>
<label for="rooms"><input type="checkbox" id="rooms" name="rooms">Rooms</label>
<label for="service"><input type="checkbox" id="service" name="service">Service</label>
<label for="none"><input type="checkbox" id="none" name="none">None</label>
Try out this
<form action="">
<input type="radio" name="purpose" value="business"> business<br>
<input type="radio" name="purpose" value="leisure"> leisure<br>
<input type="radio" name="purpose" value="passingby"> passingby<br>
<input type="radio" name="purpose" value="others"> others<br>
</form>
<p class="improve">What do we need to improve?</p>
<label for="food"><input type="checkbox" id="food" name="food">Food</label> <br>
<label for="rooms"><input type="checkbox" id="rooms" name="rooms">Rooms</label><br>
<label for="service"><input type="checkbox" id="service" name="service">Service</label><br>
<label for="none"><input type="checkbox" id="none" name="none">None</label><br>
Label should be sibling of input
<p id="purpose">
<input id="business" type="radio" name="purpose" value="business" checked><label for="business"> business</label>
<input type="radio" id="leisure" name="purpose" value="leisure"><label for="leisure">Leisure</label>
<input type="radio" id="passingby" name="purpose" value="passingby"><label for="passingby">Passing by</label>
<input type="radio" id="others" name="purpose" value="others"><label for="others">others</label>
</p>
<p class="improve">What do we need to improve?</p>

HTML - MDL Checkbox/Toggle Centering

I have tried to use both of these components in my html document but neither of them will center. With the checkbox the text gets centered but the icon will remain to the left of the page.
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
<input type="checkbox" id="checkbox-1" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Checkbox</span>
</label>
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="switch-1">
<input type="checkbox" id="switch-1" class="mdl-switch__input" checked>
<span class="mdl-switch__label"></span>
</label>
Use display:block for label and center align labels.
label
{
text-align:center;
}
.mdl-checkbox, .mdl-switch{
display:block;
}
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
<input type="checkbox" id="checkbox-1" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Checkbox</span>
</label>
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="switch-1">
<input type="checkbox" id="switch-1" class="mdl-switch__input" checked>
<span class="mdl-switch__label">Checkbox 2</span>
</label>
I used flex on the label to center the items inside. It also aligns the content vertically so your input is inline with your label.
.mdl-checkbox, .mdl-switch{
display:flex;
justify-content:center;
align-items:center;
}
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
<input type="checkbox" id="checkbox-1" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Checkbox</span>
</label>
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="switch-1">
<input type="checkbox" id="switch-1" class="mdl-switch__input" checked>
<span class="mdl-switch__label">Checkbox 2</span>
</label>

Setting up check-boxes side by side responsively using Bootstrap

I want to set up checkboxes side-by-side to visually represent something. It looks fine on my site but falls apart when trying to resize or on an iPad. I'm probably making a silly mistake but I would appreciate any corrections to my code.
http://www.bootply.com/1a5yzjMAGp
<div class="col-md-6">
<div class="col md-6">
<div class="checkbox checkbox-primary">
<input id="checkbox1" type="checkbox" disabled="disabled" />
<label for="checkbox1">
Art
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" checked="checked" />
<label for="checkbox2">
Drama
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" checked="checked" />
<label for="checkbox3">
Foods and Nutrition
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" checked="checked" />
<label for="checkbox4">
Geography
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" checked="checked" />
<label for="checkbox5">
Industrial Arts/Shop Programs
</label>
</div>
</div>
</div>
<div class="col md-6">
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" />
<label for="checkbox6">
Math
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" />
<label for="checkbox6">
Music
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" checked="checked" />
<label for="checkbox6">
Technology
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" />
<label for="checkbox6">
Science
</label>
</div>
<div class="checkbox checkbox-success">
<input id="checkbox1" type="checkbox" disabled="disabled" />
<label for="checkbox6">
Physical Education/Health
</label>
</div>
</div>
You can try giving the div with class checkbox the following properties:
.checkbox {
width:250px;
float:left;
}
You can play around with width to make it fit to you needs.
Here's the fiddle: JSBIN

How to align label and radio button?

When you read this... I probably still haven't solved my issue,
I'm trying to align the label and radiobutton, I have tried alot of "Solutions", but nothing works. I have no css on the radio buttons that i created myself.
Output: http://prntscr.com/5am898
My Code:
<div class="row">
<div class="col-md-12">
<div class="btnRadio">
<label class="radio-inline" for="gal2015lbl">
<input name="galTab" id="gal2015" value="2015" type="radio">2015
</label>
<label class="radio-inline" for="gal2014lbl">
<input name="galTab" id="gal2014" value="2014" type="radio">2014
</label>
<label class="radio-inline" for="gal2013lbl">
<input name="galTab" id="gal2013" value="2013" type="radio">2013
</label>
<label class="radio-inline" for="gal2012lbl">
<input name="galTab" id="gal2012" value="2012" type="radio">2012
</label>
<label class="radio-inline" for="galOtherlbl">
<input name="galTab" id="galOther" value="Anders" type="radio">And
</label>
</div>
</div>
</div>
Try placing the input outside the label.
<label class="radio-inline" for="galOtherlbl">
And
</label>
<input name="galTab" id="galOther" value="Anders" type="radio">
put the label in label tag like
<label class="radio inline control-label">Some label</label>
try
FIDDLE DEMO
<div class="row">
<div class="col-md-12">
<div class="btnRadio">
<input name="galTab" id="gal2015" value="2015" type="radio">
<label class="radio-inline" for="gal2015lbl">2015</label>
<input name="galTab" id="gal2014" value="2014" type="radio">
<label class="radio-inline" for="gal2014lbl">2014</label>
<input name="galTab" id="gal2013" value="2013" type="radio">
<label class="radio-inline" for="gal2013lbl">2013</label>
<input name="galTab" id="gal2012" value="2012" type="radio" />
<label class="radio-inline" for="gal2012lbl">2012</label>
<input name="galTab" id="galOther" value="Anders" type="radio"/>
<label class="radio-inline" for="galOtherlbl">And</label>
</div>
</div>
</div>