Answers.Body: <p>You could track the total used columns in a var and check if its less than 12.</p>
  
  <pre><code>{% set col_count = 0 %}
  {% for item in items %}
      {% switch item.type %}
          {% case "value1" %}
              {% set col_size = 4 %}
          {% case "value2" %}
              {% set col_size = 6 %}
      {% endswitch %}
  
      {% if not loop.first and (col_count + col_size) &gt; 12 %}
          &lt;/div&gt;
          {% set col_count = 0 %}
      {% endif %}
  
      {% if col_count == 0 %}
          &lt;div class="row"&gt;
      {% endif %}
  
      {% set col_count = col_count + col_size %}
  
      &lt;div class="column small-{{ col_size }}"&gt;
          {{ item.title }}
      &lt;/div&gt;
  
      {% if loop.last %}
          &lt;/div&gt;
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-10T08:04:14.390Z
Answers.LastActivityDate: 2018-08-10T08:04:14.390Z
Answers.UserDisplayName: RvdB
Body: <p>I need to figure out how to close out the columns if it equals 12 and then open a new row. I have a Matrix field set up with rows, but it needs to break with a new row if the columns equal 12.</p>
  
  <p>Any suggestions?</p>
  
Tags: <craft3><bootstrap-craft>
Title: Close bootstrap row and start a new row Matrix
ThreadText: # Close bootstrap row and start a new row Matrix
  
  (Asked by: username_0 on 2018-08-09)
  
  I need to figure out how to close out the columns if it equals 12 and then open a new row. I have a Matrix field set up with rows, but it needs to break with a new row if the columns equal 12.
  
  Any suggestions?
  
  **Tags:** craft3, bootstrap-craft
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-10. Score: 1
  
  You could track the total used columns in a var and check if its less than 12.
  
  ```
  {% set col_count = 0 %}
  {% for item in items %}
      {% switch item.type %}
          {% case "value1" %}
              {% set col_size = 4 %}
          {% case "value2" %}
              {% set col_size = 6 %}
      {% endswitch %}
  
      {% if not loop.first and (col_count + col_size) > 12 %}
          </div>
          {% set col_count = 0 %}
      {% endif %}
  
      {% if col_count == 0 %}
          <div class="row">
      {% endif %}
  
      {% set col_count = col_count + col_size %}
  
      <div class="column small-{{ col_size }}">
          {{ item.title }}
      </div>
  
      {% if loop.last %}
          </div>
      {% endif %}
  
  {% endfor %}
  
  ```
  
  
  ---
  
  