John Higgins
John Higgins

Reputation: 907

Foundation Grid Layout

I am struggling to get the layout sorted using the code below.

      <div class="row">
         <div class="large-6 columns">
            <div class="row collapse">
               <label>Contigency</label>
               <div class="small-9 columns">
                  <input type="text" name="contingency">
               </div>
               <div class="small-3 columns">
                  <span class="postfix">%</span>
               </div>
            </div>
         </div>
         <div class="large-3 columns">
            <div class="row collapse">
               <label style="text-align:right;">Project Management</label>
               <div class="small-2 columns">
                  <span class="prefix">$</span>
               </div>
               <div class="small-10 columns">
                  <input type="text" class="" name="project_management">
               </div>
            </div>
         </div>
      </div>
<div class="row">
   <div class="small-12 columns">
      <div class="row">
         <div class="small-8 columns">
            <label for="right-label" class="center inline"><strong>Drawings/Permits/Inspect</strong> Engineered Drawings, Permits, and Inspections Commissioning</label>
         </div>
         <div class="small-2 columns">
            <span class="prefix">$</span>
         </div>
         <div class="small-2 columns">
            <input type="text" name="project_management">
         </div>
      </div>
   </div>
</div>

It produces the following.

enter image description here

I am trying to line up the bottom input with the one above (Project management).

Any ideas where I am going wrong?

Thanks,

John

Upvotes: 0

Views: 60

Answers (1)

Brett East
Brett East

Reputation: 4322

Okay John,

It's a couple of things, first of all your bottom input is using 4 columns and the top input is only using 3 columns and secondly you are collapsing the gutters in your first row, but not collapsing them in the second.

You have a two rows, and within the top row you have nested smaller rows. You haven't nested any smaller rows in the bottom row that you have created. To get a little mathematical on you, the container for the first dollar sign is actually 1/6th of 1/3rd the screen width wide (or 1/18th), because you've nested a 2/12 column inside a 3/12 column. The second dollar sign is in a column 1/6th the width of the screen because it's in a 2/12 column. The reason that the top dollar sign doesn't fit in the second dollar sign 3 times has to do with extra width added by gutters.

But this will get it looking how you like:

<div class="row">
         <div class="large-6 columns">
            <div class="row collapse">
               <label>Contigency</label>
               <div class="small-9 columns">
                  <input type="text" name="contingency">
               </div>
               <div class="small-3 columns">
                  <span class="postfix">%</span>
               </div>
            </div>
         </div>
         <div class="large-3 large-offset-3 columns"><!-- add 'large-offset-3' to avoid any weirdness with this lining up in the future -->
            <div class="row collapse">
               <label style="text-align:right;">Project Management</label>
               <div class="small-2 columns">
                  <span class="prefix">$</span>
               </div>
               <div class="small-10 columns">
                  <input type="text" class="" name="project_management">
               </div>
            </div>
         </div>
      </div>
<div class="row">
   <div class="large-9 columns"><!-- this row will take up nine columns -->
      <div class="row collapse"><!-- collapsing this row will make it line up with the above collapsed row -->
         <div class="small-12 columns"><!-- setting this to 12 will have it fill all of the parent 9 columns -->
            <label for="right-label" class="center inline"><strong>Drawings/Permits/Inspect</strong> Engineered Drawings, Permits, and Inspections Commissioning</label>
         </div>
      </div>
   </div>
   <div class="large-3 columns"><!-- this takes up three columns and essentially matches the code for the the above row -->
      <div class="row collapse">
         <div class="small-2 columns">
            <span class="prefix">$</span>
         </div>
         <div class="small-10 columns">
            <input type="text" name="project_management">
         </div>
      </div>
   </div>
</div>

Give that a go, be sure to read the comments I left in the html explaining everything. But basically you need to make sure that your using the same number of columns if you want things to line up, and if you collapse a row, you will need to collapse other rows that you want to line it up with.

Upvotes: 1

Related Questions