title: Create new div with different %width
body: <p>I've created a section with one div. 
  The button 'click' adds new div each time when I click. 
  What I need: div 1 -> 100% width (section)
  when I click:
  div 1 and div2 (div 2 new) -> get 50% width each.
  click again:
  div1, div2 and div3 -> 30% width each. 
  click again:
  div 4 goes to next line with the same width</p>
  
  <p>Do you have any idea?
  <a href="https://jsfiddle.net/Vova_Champion/tcyw64wq/6/" rel="nofollow noreferrer">https://jsfiddle.net/Vova_Champion/tcyw64wq/6/</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>document.getElementById("button").onclick = function() {
    let ok = true;
    if (ok === true) {
      let div = document.createElement('div');
      div.className = 'new-div';
  
      document.getElementsByTagName('section')[0].appendChild(div);
    }
  };</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>section {
    display: flex;
    height: 100px;
    width: 200px;
    background: red;
    flex-wrap: wrap;
    overflow: auto;
  }
  
  div {
    display: block;
    height: 30px;
    width: 100%;
    max-width: 30%;
    background: blue;
    margin: 5px 2px;
  }
  
  #button {
    color: red
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button id="button"&gt;Click button&lt;/button&gt;
  &lt;section id="section"&gt;
    &lt;div&gt;&lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>