$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>css - Help with creating a menu with multiple columns|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

css - Help with creating a menu with multiple columns

matteradmin9PV0评论

I'm creating a custom menu in WordPress that will have multiple columns. I have it working for the most part. There are 2 issues I am having. First, when I hover over the menu item to display the drop down, I want all dropdown menus to be lined up at the start of the primary menu. Second, sometimes a link in the dropdown menu will also have a dropdown associated with that. I would like that to be in just a single column. The css to display the dropdowns is below. Let me know if you need anything else.

.site-nav ul ul {
    z-index: 1000000;
    columns: 2;
    position: absolute;
    top: -9999999px;
    left: 0;
    opacity: 0;
    background: #3498db;
    text-align: left;
}

.site-nav ul ul ul {
    z-index: 1000000;
    columns: 1;
    position: absolute;
    top: -9999999px;
    left: 0;
    opacity: 0;
    background: #3498db;
    text-align: left;
}

.site-nav ul li:hover > ul {
    position: absolute;
    top: 95%;
    opacity: 1;
    left: 0;
}

EDIT

Screenshots of what is happening:

I'm creating a custom menu in WordPress that will have multiple columns. I have it working for the most part. There are 2 issues I am having. First, when I hover over the menu item to display the drop down, I want all dropdown menus to be lined up at the start of the primary menu. Second, sometimes a link in the dropdown menu will also have a dropdown associated with that. I would like that to be in just a single column. The css to display the dropdowns is below. Let me know if you need anything else.

.site-nav ul ul {
    z-index: 1000000;
    columns: 2;
    position: absolute;
    top: -9999999px;
    left: 0;
    opacity: 0;
    background: #3498db;
    text-align: left;
}

.site-nav ul ul ul {
    z-index: 1000000;
    columns: 1;
    position: absolute;
    top: -9999999px;
    left: 0;
    opacity: 0;
    background: #3498db;
    text-align: left;
}

.site-nav ul li:hover > ul {
    position: absolute;
    top: 95%;
    opacity: 1;
    left: 0;
}

EDIT

Screenshots of what is happening:

Share Improve this question edited Apr 30 at 20:24 Darth Mikey D asked Apr 30 at 19:38 Darth Mikey DDarth Mikey D 1051 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

the following code should help and I have added comments for explanation:


.site-nav ul ul {
    z-index: 1000000;
    position: absolute;
    top: -9999999px;
    left: 0; /* Align with the left edge of the parent */
    transform: none; /* Cancel the centering transform */
    opacity: 0;
    background: #3498db;
    text-align: left;
    columns: auto; /* Remove multi-column layout */
}

.site-nav ul ul ul {
    z-index: 1000000;
    position: absolute;
    top: 0;
    left: 100%;
    opacity: 0;
    background: #3498db;
    text-align: left;
    columns: auto; /* Ensure only one column for deeper menus */
}

.site-nav ul li:hover > ul {
    position: absolute;
    top: 100%;
    left: 0; /* Align with left edge of parent */
    transform: none; /* Cancel centering */
    opacity: 1;
}

Post a comment

comment list (0)

  1. No comments so far