I am making an app that displays 100 bars of random heights inside of #bar-container which is a div. For some reason, my app has some white spaces to the right of my bars. I want the div to shrink to the size of the content and then center on the screen. My app looks like this:
JSX:
return (
<div id="main-container">
<button onClick={() => newArray()}>New Array</button>
<div id="bar-container">
{arr.map((value, index) => (
<div
className='bar'
key={index}
style={{
backgroundColor: "lightgreen",
height: `${value}px`
}}
>
{value}
</div>
))}
</div>
</div>
CSS:
#bar-container {
align-items: flex-end;
display: flex;
margin: 100px;
}
.bar {
margin: 0 2px;
}
I tried to include auto in margin for #bar-container but it doesn't center the bars and it does not remove that extra white space.