This is what the code will display now:
This is what I want it to display
The positioning of the components is what’s driving me nuts. I can not seem to get the "Gender:" , "Gender RadioButton list" , "Age:" , "Age RadioButton list" to display in 4 columns on a single row.
There are going to be several different survey questions, so I do need to make the display based on CSS.
How, (or where) can learn how to properly use the and <Div class="col"???>? It’s like learning Klingon to me.
.form-container {
position: relative;
margin: 0 auto;
border-radius: 1.25rem;
border: 0.375rem solid;
border-color: #000000;
background-color: #FFFFFF;
box-shadow: #339900 0.625rem 1.25rem 1.25rem -0.625rem;
padding-top: 1.25rem;
width: 75%;
height: 40%;
}
.form-container .RadioArray {
width: 40rem;
align-self: center;
padding-left: 0.938rem;
padding-right: 0.938rem;
padding-top: 0.313rem;
padding-bottom: 0.313rem;
border-style: groove;
border-width: 0.125rem;
border-color: #000000;
background-color: #FF0000;
text-align: center;
*/
}
.form-container .RadioBox {
width: fit-content;
padding-left: 0.938rem;
padding-right: 0.938rem;
padding-top: 0.313rem;
padding-bottom: 0.313rem;
border-style: groove;
border-width: 0.125rem;
border-color: #009900;
background-color: #B3FFB2;
border-radius: 1.25rem;
font-family: Cabin SemiBold, sans-serif;
text-align: center;
}
.form-container .spread {
padding-left: 1rem;
padding-top: .5rem;
font-family: Valken, serif;
color: #8A8A8A;
height: 2.5rem;
font-size: 1.150rem;
font-weight: lighter;
text-align: centre;
}
h4 {
font-family: fantasy, "Cabin Medium";
font-size: 1.50rem;
font-weight: bold;
color: #CCCCCC;
text-align: center;
}
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<!-- Bootstrap Font Icon CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="PlayRoom.css" type="text/css">
<title>PlayRoom</title>
</head>
<body>
<h4>Optional</h4>
<div class="form-container">
<div class="RadioArray">
<div class="row">
<div class="col-sm-5">
<div class="input-group">
<span class="spread">Gender</span>
</div>
<div class="RadioBox">
<div class="form-check">
<input type="radio" class="form-check-input" id="gender1" name="cGender" value="No Answer" checked>
<label class "form-check-label" for="gender1">Declined</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="gender2" name="cGender" value="Male">
<label class "form-check-label" for="gender3">Male</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="gender3" name="cGender" value="Female">
<label class "form-check-label" for="gender3">Female</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="gender4" name="cGender" value="Neutral">
<label class "form-check-label" for="gender4">Neutral</label>
</div>
</div>
</div>
<div class="col-sm-5">
<div class="input-group">
<span class="spread">Age</span>
</div>
<div class="RadioBox">
<div class="form-check">
<input type="radio" class="form-check-input" id="cAge1" name="cAgeGroup" value="No Answer" checked />
<label class "form-check-label" for='cAge1'>Declined</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="cAge2" name="cAgeGroup" value="under 19" />
<label class "form-check-label" for='cAge2'>under 19</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="cAge3" name="cAgeGroup" value="19-40" />
<label class "form-check-label" for='cAge3'>19 to 40</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="cAge4" name="cAgeGroup" value="over 40" />
<label class "form-check-label" for='cAge4'>Over 40</label>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
2
Answers
Try using this approach on your html –
Explanation: a row can be divided into 12 cols and based on your requirement you need 2 cols for the headings "gender" & "age" which won’t need much space hence we are using col-md-2 , then the list requires a bit more space that’s why we use col-md-4. And, if you notice all the cols add up to 12.
Bootstrap is based on 12 columns. Containers are a block with/without margin depending on if you choose
container
orcontainer-fluid
Rows arerow
and a row can have columns likecol-6
is size columns taken. You don’t have to have ALL 12 columns.You had some class without the = like
class "someclass"
also.This is not 100% you desire but that is really just the colors/style visually to get you started.
You had too much CSS custom perhaps. Bootstrap has classes for padding
p-3
for example, borderborder
etc. and some additional can also probably be removed.As for your question reference the "grid" system of bootstrap: https://getbootstrap.com/docs/5.0/layout/grid/
For example I used
col-6
but you might just needcol
so when you get 3 you don’t have to changecol-6
tocol-4