skip to Main Content

I’ve tried everything including similar questions/answers to solve this problem but can’t get it to come together.

I’m using Flexbox rows and columns and what I am trying to do is to create four rows of input fields with four items in each (just the final one has two for now) and then to align those such that the labels that go with the input fields align vertically with the row underneath them.
At the moment I can’t get them to straighten up so it’s very uneven.

So, for example, labels ‘Size Meaning:’, ‘Class;’, and ‘Unit:’ should all be vertically aligned and starting in the same place.

How so I align the labels in the columns vertically?

This is an image of how this looks right now:
input_fields_img

p { font-size: 24px; }
li { font-size: 24px; }

.page-wrapper {
    margin: 80px;
    align-content: flex-start;
  }

.row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .column {
    display: flex;
    flex-direction: column;
    flex-basis: 100%;
    flex: 1;
  }

  .li-label, .li-input {
    display: inline-block;
  }

  .li-label {
    min-width: 80px;
  }
<div class='page-wrapper'>
    <div class='row'>
      <div class='column'>
        <form>
            <label for="name"> Name:</label>
            <input type="name" id="name" name="name">
        </form>
      </div>
      <div class='column'>
        <form>
            <label for="value">Value:</label>
            <input type="value" id="size_value" name="value">
        </form>
      </div>
      <div class='column'>
        <form>
            <label for="size">Size:</label>
            <input type="size" id="size" name="size">
        </form>
      </div>
      <div class='column'>
        <form>
            <label for="price">Price:</label>
            <input type="price" id="price_at_size" name="price">
        </form>
      </div>
    </div>

      <!-------------------END ROW 1----------------------------------------->

      <!-- <div class='page-wrapper'> -->
        <div class='row'>
          <div class='column'>
            <form>
                <label for="currency">Currency:</label>
                <input type="currency" id="currency" name="currency">
            </form>
          </div>
          <div class='column'>
            <form>
                <label for="year">Year:</label>
                <input type="year" id="series_name" name="year">
            </form>
          </div>
          <div class='column'>
            <form>
                <label for="class">Class:</label>
                <input type="class" id="class" name="class">
            </form>
          </div>
          <div class='column'>
            <form>
                <label for="usd">USD:</label>
                <input type="usd" id="usd" name="usd">
            </form>
          </div>
        <!-- </div> -->

            <!-------------------END ROW 2----------------------------------------->

        <!-- <div class='page-wrapper'> -->
            <div class='row'>
                <div class='column'>
                <form>
                    <label for="style">Style:</label>
                    <input type="style" id="style" name="style">
                </form>
                </div>
                <div class='column'>
                <form>
                    <label for="result">Result:</label>
                    <input type="result" id="result" name="result">
                </form>
                </div>
                <div class='column'>
                <form>
                    <label for="unit">Unit:</label>
                    <input type="unit" id="unit" name="unit">
                </form>
                </div>
                <div class='column'>
                <form>
                    <label for="Result1">Result1:</label>
                    <input type="Result1" id="Result1" name="Result1">
                </form>
                </div>
            </div>

                <!-------------------END ROW 3----------------------------------------->

        <!-- <div class='text-align:center'>
            <div class='row'>
                <div class='column'>
                <form>
                    <label for="level">Level:</label>
                    <input type="level" id="level" name="level">
                </form>
                </div>
                <div class='column'>
                <form>
                    <label for="reference">Reference:</label>
                    <input type="reference" id="reference" name="reference">
                </form>
                </div>
            </div>
        </div> -->
<!-- 
        <div style="text-align:center"></div>
            <form>
                <label for="sources">Sources:</label>
                <input type="sources" id="sources" name="sources">
                <label for="notes">Notes:</label>
                <input type="notes" id="notes" name="notes">
            </form>
        </div>

                <!-------------------END ROW 4---------------------------------------->
        <br>

    <div style="text-align: center">
        <input type="submit" id="submit" name="submit">
    </div>

2

Answers


  1. Isn’t what you want placing each element to it’s own column class like this? Also you need to wrap all the elements in only one form:

    <div class='page-wrapper'>
      <form>
        <div class='row'>
          <div class='column'>
            <label for="name"> Name:</label>
          </div>
          <div class='column'>
            <input type="name" id="name" name="name">
          </div>
          <div class='column'>
            <label for="value">Value:</label>
          </div>
          <div class='column'>
            <input type="value" id="size_value" name="value">
          </div>
          <div class='column'>
            <label for="size">Size:</label>
          </div>
          <div class='column'>
            <input type="size" id="size" name="size">
          </div>
          <div class='column'>
            <label for="price">Price:</label>
          </div>
          <div class='column'>
            <input type="price" id="price_at_size" name="price">
          </div>
        </div>
        <!-------------------END ROW 1----------------------------------------->
        <!-- <div class='page-wrapper'> -->
        <div class='row'>
          <div class='column'>
            <label for="currency">Currency:</label>
          </div>
          <div class='column'>
            <input type="currency" id="currency" name="currency">
          </div>
          <div class='column'>
            <label for="year">Year:</label>
          </div>
          <div class='column'>
            <input type="year" id="series_name" name="year">
          </div>
          <div class='column'>
            <label for="class">Class:</label>
          </div>
          <div class='column'>
            <input type="class" id="class" name="class">
          </div>
          <div class='column'>
            <label for="usd">USD:</label>
          </div>
          <div class='column'>
            <input type="usd" id="usd" name="usd">
          </div>
          <!-- </div> -->
          <!-------------------END ROW 2----------------------------------------->
          <!-- <div class='page-wrapper'> -->
          <div class='row'>
            <div class='column'>
              <label for="style">Style:</label>
            </div>
            <div class='column'>
              <input type="style" id="style" name="style">
            </div>
            <div class='column'>
              <label for="result">Result:</label>
            </div>
            <div class='column'>
              <input type="result" id="result" name="result">
            </div>
            <div class='column'>
              <label for="unit">Unit:</label>
            </div>
            <div class='column'>
              <input type="unit" id="unit" name="unit">
            </div>
            <div class='column'>
              <label for="Result1">Result1:</label>
            </div>
            <div class='column'>
              <input type="Result1" id="Result1" name="Result1">
            </div>
          </div>
          <!-------------------END ROW 3----------------------------------------->
          <!-- <div class='text-align:center'><div class='row'><div class='column'><label for="level">Level:</label></div><div class='column'><input type="level" id="level" name="level"></div><div class='column'><label for="reference">Reference:</label></div><div class='column'><input type="reference" id="reference" name="reference"></div></div></div> -->
          <!-- 
            <div style="text-align:center"></div><label for="sources">Sources:</label></div><div class='column'><input type="sources" id="sources" name="sources"></div><div class='column'><label for="notes">Notes:</label></div><div class='column'><input type="notes" id="notes" name="notes"></div>
                                                                <!-------------------END ROW 4---------------------------------------->
          <br>
          <div style="text-align: center">
            <input type="submit" id="submit" name="submit">
          </div>
        </div>
      </form>
    </div>
    
    Login or Signup to reply.
  2. there are lot of work need to be done in HTML part.

    But i have just ignored it and added missing closing div in snippet.

    you can change the values of width as per your need for form elements.

    p { font-size: 24px; }
    li { font-size: 24px; }
    
    .page-wrapper {
        /*margin: 80px;*/
        align-content: flex-start;
        font-family: sans-serif;
        font-size: 13px;
    width: 740px;
      }
    
    .row {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 5px;
        margin-bottom: 5px;
      }
    
      .column {
        display: flex;
        flex-direction: column;
        flex-basis: 100%;
        flex: 1;
      }
    
      .li-label, .li-input {
        display: inline-block;
      }
    
      .li-label {
        min-width: 80px;
      }
      
    .column form { display: flex; }
    .column form label{ min-width: 70px; }
    .column form input{ max-width: 98px; }
    <div class='page-wrapper'>
        <div class='row'>
          <div class='column'>
            <form>
                <label for="name"> Name:</label>
                <input type="name" id="name" name="name">
            </form>
          </div>
          <div class='column'>
            <form>
                <label for="value">Value:</label>
                <input type="value" id="size_value" name="value">
            </form>
          </div>
          <div class='column'>
            <form>
                <label for="size">Size:</label>
                <input type="size" id="size" name="size">
            </form>
          </div>
          <div class='column'>
            <form>
                <label for="price">Price:</label>
                <input type="price" id="price_at_size" name="price">
            </form>
          </div>
        </div>
    
          <!-------------------END ROW 1----------------------------------------->
    
          <!-- <div class='page-wrapper'> -->
            <div class='row'>
              <div class='column'>
                <form>
                    <label for="currency">Currency:</label>
                    <input type="currency" id="currency" name="currency">
                </form>
              </div>
              <div class='column'>
                <form>
                    <label for="year">Year:</label>
                    <input type="year" id="series_name" name="year">
                </form>
              </div>
              <div class='column'>
                <form>
                    <label for="class">Class:</label>
                    <input type="class" id="class" name="class">
                </form>
              </div>
              <div class='column'>
                <form>
                    <label for="usd">USD:</label>
                    <input type="usd" id="usd" name="usd">
                </form>
              </div>
              </div>
            <!-- </div> -->
    
                <!-------------------END ROW 2----------------------------------------->
    
            <!-- <div class='page-wrapper'> -->
                <div class='row'>
                    <div class='column'>
                    <form>
                        <label for="style">Style:</label>
                        <input type="style" id="style" name="style">
                    </form>
                    </div>
                    <div class='column'>
                    <form>
                        <label for="result">Result:</label>
                        <input type="result" id="result" name="result">
                    </form>
                    </div>
                    <div class='column'>
                    <form>
                        <label for="unit">Unit:</label>
                        <input type="unit" id="unit" name="unit">
                    </form>
                    </div>
                    <div class='column'>
                    <form>
                        <label for="Result1">Result1:</label>
                        <input type="Result1" id="Result1" name="Result1">
                    </form>
                    </div>
                </div>
    
                    <!-------------------END ROW 3----------------------------------------->
    <!--
            <div class='text-align:center'>
                <div class='row'>
                    <div class='column'>
                    <form>
                        <label for="level">Level:</label>
                        <input type="level" id="level" name="level">
                    </form>
                    </div>
                    <div class='column'>
                    <form>
                        <label for="reference">Reference:</label>
                        <input type="reference" id="reference" name="reference">
                    </form>
                    </div>
                </div>
            </div> -->
    <!-- 
            <div style="text-align:center"></div>
                <form>
                    <label for="sources">Sources:</label>
                    <input type="sources" id="sources" name="sources">
                    <label for="notes">Notes:</label>
                    <input type="notes" id="notes" name="notes">
                </form>
            </div>
    
                    <!-------------------END ROW 4---------------------------------------->
            <br>
    
        <div style="text-align: center">
            <input type="submit" id="submit" name="submit">
        </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search