I have really big problem with flex boxes and can't find any answer to this. Below I will put some code. A problem is that a black background doesn't expand to right with a content. Do you have any idea how to fix that? How to force container to expand depending on content number of columns?
The goal is to reach something like that: https://i.stack.imgur.com/xXxmP.jpg
.categories li ul {
list-style: none;
display: flex;
flex-direction: column;
flex-wrap: wrap;
position: absolute;
width: auto;
padding-left: 0;
background-color: black;
color: red;
max-height: 200px;
}
.categories li ul li {
margin-right: 20px;
}
<ul class="categories">
<li>
<a href="#">Categories</a>
<ul>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
<li>Aaa</li>
</ul>
</li>
</ul>