Positioning CSS components

Joined
Aug 16, 2022
Messages
52
Reaction score
2
Hi Everybody,

The code I have provided will display this result:
CaptureBad.png

What I want to display is this:
CaptureGood.jpg


The positioning of the components is what's driving me nuts. I can not seem to get the Gender+RadioButton list and
the Age Group+RadioButton list 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 <Div class="row???"> and <Div class="col"???>? It's still like learning
Klingon to me.


HTML:
<!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>
  <div class="form-container">
      <h4>Optional</h4>
        <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>

CSS:
.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;
     height: 30%;
    width: 60%;
    padding-top: 1.25rem;

}


.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;
}
 
Joined
Jul 4, 2023
Messages
366
Reaction score
41
Did you try in that way ... 4 columns?
[ code on-line ]
CSS:
.form-container {
  position: relative;
  margin: 0 auto;
  border-radius: 1.25rem;
  border: 0.375rem solid #000000;
  background-color: #2bdeda;
  box-shadow: #339900 0.625rem 1.25rem 1.25rem -0.625rem;
  max-width: 60%;
  padding: 1.25rem 0;
  box-sizing: border-box;
}
.form-container h4 {
  font-family: fantasy, "Cabin Medium";
  font-size: 1.50rem;
  font-weight: bold;
  text-align: center;
}
.form-container .spread {
  padding-left: 1rem;
  padding-top: .5rem;
  font-family: Valken, serif;
  color: #000000;
  font-size: 1.150rem;
  font-weight: bold;
  text-align: right;
}
.form-container .radioBox {
  width: fit-content;
  padding: 0.313rem 0.938rem;
  border-style: groove;
  border-width: 0.125rem;
  border-color: #009900;
  background-color: #B3FFB2;
  border-radius: 1.25rem;
  font-family: Cabin SemiBold, sans-serif;
}
.form-container .radioBox ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
HTML:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">


<div class="container-fluid">
  <div class="form-container">
    <div class="row">
      <div class="col-md-12 col-sm-12">
        <h4>Optional</h4>
      </div>
    </div>
    <div class="row">
      <div class="col-md-3 col-sm-6">25%-50% desktop, 100% mobile</div>
      <div class="col-md-3 col-sm-6">25%-50% desktop, 100% mobile</div>
      <div class="col-md-3 col-sm-6">25%-50% desktop, 100% mobile</div>
      <div class="col-md-3 col-sm-6">25%-50% desktop, 100% mobile</div>
    </div>
  </div>
</div>

1700575176988.png



suggestion of what your code might look like
[ code on-line ]
CSS:
.form-container {
  position: relative;
  margin: 0 auto;
  border-radius: 1.25rem;
  border: 0.375rem solid #000000;
  background-color: #2bdeda;
  box-shadow: #339900 0.625rem 1.25rem 1.25rem -0.625rem;
  max-width: 60%;
  padding: 1.25rem 0;
  box-sizing: border-box;
}
.form-container h4 {
  font-family: fantasy, "Cabin Medium";
  font-size: 1.50rem;
  font-weight: bold;
  text-align: center;
}
.form-container .spread {
  padding-left: 1rem;
  padding-top: .5rem;
  font-family: Valken, serif;
  color: #000000;
  font-size: 1.150rem;
  font-weight: bold;
  text-align: right;
}
.form-container .radioBox {
  width: fit-content;
  padding: 0.313rem 0.938rem;
  border-style: groove;
  border-width: 0.125rem;
  border-color: #009900;
  background-color: #B3FFB2;
  border-radius: 1.25rem;
  font-family: Cabin SemiBold, sans-serif;
}
.form-container .radioBox ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
HTML:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">


<div class="container-fluid">
  <div class="form-container">
    <div class="row">
      <div class="col-md-12 col-sm-12">
        <h4>Optional</h4>
      </div>
    </div>
    <div class="row">
      <div class="col-md-3 col-sm-6 spread">Gender:</div>
      <div class="col-md-3 col-sm-6 radioBox">
        <ul>
          <li>
            <input type="radio" class="form-check-input" id="gender1" name="cGender" value="No Answer" checked>
            <label class="form-check-label" for="gender1">Declined</label>
          </li>
          <li>
            <input type="radio" class="form-check-input" id="gender2" name="cGender" value="Male">
            <label class="form-check-label" for="gender2">Male</label>
          </li>
          <li>
            <input type="radio" class="form-check-input" id="gender3" name="cGender" value="Female">
            <label class="form-check-label" for="gender3">Female</label>
          </li>
          <li>
            <input type="radio" class="form-check-input" id="gender4" name="cGender" value="Neutral">
            <label class="form-check-label" for="gender4">Neutral</label>
          </li>
        </ul>
      </div>
      <div class="col-md-3 col-sm-6 spread">Age group:</div>
      <div class="col-md-3 col-sm-6 radioBox">
        <ul>
          <li>
            <input type="radio" class="form-check-input" id="cAge1" name="cAgeGroup" value="No Answer" checked>
            <label class="form-check-label" for="cAge1">Declined</label>
          </li>
          <li>
            <input type="radio" class="form-check-input" id="cAge2" name="cAgeGroup" value="under 19">
            <label class="form-check-label" for="cAge2">under 19</label>
          </li>
          <li>
            <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>
          </li>
          <li>
            <input type="radio" class="form-check-input" id="cAge4" name="cAgeGroup" value="over 40">
            <label class="form-check-label" for="cAge4">Over 40</label>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

1700575541303.png
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top