OK, so what I need is to render nested ul
/ li
into 3 columns.
I want to do this with pure CSS (and no JS) and I have 2 semi-working examples.
Example 1 via display: grid
https://jsfiddle.net/slick/1rtucfmL/2/
So for parent ul
you simply specify display: grid
with grid-template-columns: 1fr 1fr 1fr
and you have 3 columns. When you hover on item, then child ul
renders nicely.
This example however has issue where items are rendered horizontally (don't want that):
a b c
d e f
g h i
rather than vertically (this is what I need):
a d g
b e h
c f i
Someone asked this before and the solution is to define qty. of rows. I can't do this because I have dynamic quantity of rows and I don't want to hardcode any values.
So I went to the second example…
Example 2 via column-count: 3
https://jsfiddle.net/slick/g5p2j8bo/2/
This renders column items as I want, from A to Z vertically. However the issue is that when you hover on item, the child ul
is shown in a very bizarre way (sometimes it's broken into columns as well, I don't want this).
If only I could fix this child positioning then example 2 would suit my needs.
I have no idea why this happens. I tried to set column-count: 1
because I thought that maybe it inherits 3
from parent but that didn't help.
Any hints? Thanks!