I want the center of the dropdown menu aligns with the center of the parent menu item. Using css (stylus). But the width of the dropdown menu is not fixed, the width of the submenu items is dynamic, meaning it can change based on the content inside.
But now it looks like this:
It should look like this:
The structure of my html is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<ulid="nav"> <divclass="menu-items"> <liclass="item-name"><aclass="name-a"href="/"one-link-mark="yes"><iclass="fas fa-home"></i> Home</a></li> <liclass="item-name"><aclass="name-a"href="/null"one-link-mark="yes"><iclass="fas fa-list"></i> Lab</a> <ulclass="submenu-items"> <liclass="subitem-name"><ahref="/art"one-link-mark="yes"><iclass="fas fa-palette"></i> This is a long name</a></li> <liclass="subitem-name"><ahref="/"one-link-mark="yes"><iclass="fas fa-chart-bar"></i> ThisIsALongName</a></li> </ul> </li> <liclass="item-name"><aclass="name-a"href="/archives"one-link-mark="yes"><iclass="fas fa-archive"></i> Archives</a></li> <liclass="item-name"><aclass="name-a"href="/tags"one-link-mark="yes"><iclass="fas fa-tag"></i> Tag</a></li> </div> </ul>
This is the solution I found. However, the transform is not working at all. I’m not sure why.
I’ve checked the developer tool console, the style is showed correctly and is not crossed by other styles. So, I comment each styles assigned to the .submenu-items, to see if transform is effected by other styles.