title: How could I evenly split up buttons on a single line using HTML and CSS?
body: <p>In my HTML code I am trying to create a couple buttons inside a modal. I am using Bootstrap for this. Within the footer part, I am trying to split these buttons evenly among the width of the modal (or modal footer).</p>
  
  <p>I could be using Bootstrap columns to achieve this but the padding (between the elements containing the <code>.col-*</code> class) might be a bit too big for this purpose. I could assign a width but this does not split the elements evenly among the amount of space available.</p>
  
  <p>This is what I tried so far:</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).ready(function() {
    $(".modal").modal();
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.foo {
    /* Hardcoded width, how could I make it that when adding buttons, width is split among amount of buttons? */
    float: left;
    width: 30%;
    margin: 0 5px;
  }
  
  .bar {
    /* Not working to center the buttons: */
    margin: 0 auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"&gt;
    &lt;div class="modal-dialog modal-lg" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
          &lt;h4 class="modal-title"&gt;Modal title&lt;/h4&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;p&gt;&amp;hellip;&lt;/p&gt;
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;!-- Content with three evenly spread/divided buttons on a single line --&gt;
          &lt;div class="bar"&gt;
            &lt;div class="foo"&gt;
              &lt;button type="button" class="btn btn-default btn-block"&gt;Button 1&lt;/button&gt;
            &lt;/div&gt;
            &lt;div class="foo"&gt;
              &lt;button type="button" class="btn btn-default btn-block"&gt;Button 2&lt;/button&gt;
            &lt;/div&gt;
            &lt;div class="foo"&gt;
              &lt;button type="button" class="btn btn-default btn-block"&gt;Button 3&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;!-- End of content --&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://jsfiddle.net/51xzr9jh/" rel="nofollow noreferrer">JSFiddle</a></p>
  
  <p>Setting the width to a 30% obviously does not always make the buttons split evenly (e.g. if I add another button, the buttons are not evenly spread anymore). Also notice that the buttons are somewhat leaning to the left. I Would like the buttons to grow with the size of the modal (a.k.a. responsiveness). What is the best way to split/spread the buttons on a single line within the Modal's footer?</p>