Increase width when scroll bar

Giganews Newsgroups
Subject: Increase width when scroll bar
Posted by:  Andrew Poulos (ap_pr…@hotmail.com)
Date: Thu, 18 Feb 2021

Say I have a div with

  display:flex
  flex-direction: column;
  width: 40px
  overflow-y: auto
  max-height: 100%
  box-sizing: border-box;

containing a column of items. Once the number of items exceeds the
max-height a scroll bar appears. The scroll bar takes some of the 40
pixel width of the div.

How can I code it so that if a scroll bar needs to appear the width of
the div increases by at least the width of the scroll bar? As the div's
items are relatively small I don't want nearly half their width covered
by a scroll bar.

Andrew Poulos

Replies