title: CSS tabs width auto-resize
body: <p>I am creating a new layout to learn about flex, some kind of holy grail but in flex. The problem I am facing is with the tabs nav, because I want the layout to work fine in PC and mobile I need the tabs to autoresize.</p>
  <p>No scripts no plugins no complications, clean and simple CSS only.</p>
  <p>I want the layout to display the tabs nav with a maximun of 1281 px width on PC and if the screen is smaller like on mobiles or tablets it will use the full with of small devices.</p>
  <p>I am doing it this way:</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>function openCity(evt, cityName) {
    var i, tabcontent, tablinks;
    
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i &lt; tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
    
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i &lt; tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
  }
  
  // Get the element with id="defaultOpen" and click on it
  document.getElementById("defaultOpen").click();</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>@charset "UTF-8";
  html,
  body {
    height: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
    background: #fff;
  }
  
  body {
    display: flex;
    flex-direction: column;
  }
  
  header {
    height: 75px;
    margin: 0 auto;
  }
  
  main {
    flex: auto;
    margin: 0 auto;
  }
  
  .contenido {
    width: 1280px;
    background: #212121;
    height: auto;
    border-radius: 4px;
    border: 2px solid #000000;
    padding: 10px;
  }
  
  
  /* Style the tab */
  
  .tab {
    overflow: hidden;
    border-radius: 4px;
    margin: 0 auto;
    text-align: center;
    border: 1px solid #555555;
    background-color: #212121;
  }
  
  
  /* Style the buttons inside the tab */
  
  .tab button {
    background-color: #212121;
    display: inline-block;
    border: none;
    outline: none;
    cursor: pointer;
    height: 100px;
    width: 20%;
    transition: 0.3s;
    font-size: 17px;
    color: #fff;
  }
  
  
  /* Change background color of buttons on hover */
  
  .tab button:hover {
    background-color: #ddd;
  }
  
  
  /* Create an active/current tablink class */
  
  .tab button.active {
    background-color: orange;
    color: #fff;
  }
  
  
  /* Style the tab content */
  
  .tabcontent {
    display: none;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-top: none;
  }
  
  footer {
    height: 25px;
    margin: 0 auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header&gt;header&lt;/header&gt;
  &lt;main&gt;
    &lt;div class="contenido"&gt;
      &lt;div class="tab"&gt;
        &lt;button class="tablinks" onclick="openCity(event, 'welcome')" id="defaultOpen"&gt;Welcome&lt;/button&gt;
        &lt;button class="tablinks" onclick="openCity(event, 'airdrop')"&gt;Airdrop&lt;/button&gt;
        &lt;button class="tablinks" onclick="openCity(event, 'presale')"&gt;Presale&lt;/button&gt;
        &lt;button class="tablinks" onclick="openCity(event, 'roadmap')"&gt;Roadmap&lt;/button&gt;
      &lt;/div&gt;
      &lt;div id="welcome" class="tabcontent"&gt;
        &lt;h3&gt;Welcome&lt;/h3&gt;
        &lt;p&gt;London is the capital city of England.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="airdrop" class="tabcontent"&gt;
        &lt;h3&gt;Airdrop&lt;/h3&gt;
        &lt;p&gt;Paris is the capital of France.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="presale" class="tabcontent"&gt;
        &lt;h3&gt;Presale&lt;/h3&gt;
        &lt;p&gt;Paris is the capital of France.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="roadmap" class="tabcontent"&gt;
        &lt;h3&gt;Roadmap&lt;/h3&gt;
        &lt;p&gt;Tokyo is the capital of Japan.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/main&gt;
  &lt;footer&gt;footer&lt;/footer&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>The problem is that using the width 1281 in css it does not autoresize in small screens like mobile, if I set % width it display wrong on small devices too...</p>
  <p>What I need is:</p>
  <p>On pc max 1281 px width, on mobile 98% of the device width. The Tabs is the problem. I want the tabs to be a 25% of any screen resolution so they always display inline blocks like.</p>
  <p>What is the problem ?</p>
  <p>Link to Fiddle for real time demo
  <a href="https://jsfiddle.net/vzd8re35/" rel="nofollow noreferrer">https://jsfiddle.net/vzd8re35/</a></p>