title: Avoid vertical scrollbar shift in container
body: <p>In html, I have a panel with a fixed height which contains cards. It can contain one card or many cards. Hence, because the panel has a fixed height, it can be needed to have a scrollbar displayed in order to visualize all cards. This works properly with the property <code>overflow: auto</code>.</p>
  <p>However, when the scrollbar is displayed, cards are shift. I would like to avoid that or at least hide this shift with a trick. I checked a lot of similar questions that suggests to use <code>padding-left: calc(100vw - 100%);</code> but it did not work since it is not the body scrollbar. <strong>The width of the card needs to be responsive according to the container's width.</strong></p>
  <p>Something that could work is to set the <code>overflow: overlay</code> and add a <code>padding-right</code>. However, this is not a standard and not compatible with firefox.</p>
  <p>Here, you can find a reproduce example:</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>let flag = true;
  
  const setHeight = () =&gt; {
    if (flag) {
      document.getElementById('container').style.setProperty('height', '100%');
    } else {
      document.getElementById('container').style.removeProperty('height');
    }
    flag = !flag;
  };
  
  document.getElementById('button').addEventListener('click', setHeight);
  setHeight();</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.panel-container {
    height: 300px;
    width: 510px;
    padding: 8px 20px 0;
    background-color: blue;
    overflow: auto;
  }
  
  .card {
    height: 86px;
    width: 100%;
    background-color: grey;
    border-radius: 3px;
    border: 1px solid red;
    margin-bottom: 10px;
    cursor: pointer;
  }
  
  .scrollbar::-webkit-scrollbar-track {
    width: 14px;
  }
  
  .scrollbar::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 4px solid green;
  }
  
  .scrollbar::-webkit-scrollbar-corner {
    background-color: transparent;
  }
  
  .scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button id="button"&gt;With/Without overflow&lt;/button&gt;
  &lt;div id="container" class="panel-container scrollbar"&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-left-container"&gt;&lt;/div&gt;
      &lt;div class="card-middle-container"&gt;&lt;/div&gt;
      &lt;div class="card-right-container"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>