Making the width of nested ul full width - css

I am trying to making a responsive menu, that takes on full width in the sub's sub-menu but my problem is that it is restricted to the parent li which is 33.3%, I want my submenu of the submenu to be 100% width as well. Here is my codepen
and my code as follows
<div class="mobile-menu hidden-lg-up active">
<ul id="menu-mobile-menu" class="links-middle-group">
<li id="menu-item-31" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-31">About
<ul class="sub-menu">
<li id="menu-item-70" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-70">Section 1
<ul class="sub-menu">
<li id="menu-item-72" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-72">Sub section 1</li>
<li id="menu-item-71" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-71">Sub section 2</li>
<li id="menu-item-73" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-73">Sub section 3</li>
</ul>
</li>
<li id="menu-item-33" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-33">Section 2</li>
<li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41">Section 3</li>
</ul>
</li>
<li id="menu-item-35" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-35">Portfolio
<ul class="sub-menu">
<li id="menu-item-42" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-42">Portfolio 1</li>
<li id="menu-item-43" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-43">Portfolio 2</li>
<li id="menu-item-44" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-44">Portfolio 3</li>
</ul>
</li>
<li id="menu-item-37" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-37">Contact
<ul class="sub-menu">
<li id="menu-item-30" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-30">facebook</li>
<li id="menu-item-65" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-65">Twitter</li>
<li id="menu-item-34" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-34">Email me</li>
</ul>
</li>
</ul>
</div>
The menu heading of sub section 1, 2 and 3 will have it's own column, so restricting to height cannot work. Each section when clicked on will display it's own section (not demostarted in demo) I also tried position but that makes the second link portfolio jumps up and ruin the layout.Maybe I am doing it wrong?

Since your list items are 33% of the full width, the nested list at most can take up the width of its parent. Since it's 100% of 33%, you could set the width of your nested .sub-menu's to 300%.
.sub-menu .sub-menu {
width: 300%;
}
I'd also recommend creating another class name for targeting nested sub-menu's because this selector looks a bit funny.
Note: This isn't the best for maintainability since you'd need to update it whenever you added or removed list items, and it relies on an assumption of how many list items are there. Absolutely positioning the nested sub-menu within a relatively-positioned .menu-item would work best but then you'd need to know the height of the list items. Although that's a lot easier to maintain than width.

Related

custom last child menu item html in wordpress

in my menu item need to change last child html can help me to change it. thanks
my html:
<ul class="sub-menu">
<li id="menu-item-21" class="menu-item menu-item-type-post_type menu-item-object-page icon-chevron-right menu-item-21">Sample Page</li>
</ul>
like this:
<ul class="sub-menu">
<li id="menu-item-21" class="menu-item menu-item-type-post_type menu-item-object-page icon-chevron-right menu-item-21">Sample Page<i class="icon-chevron-right"></i></li>
</ul>

WordPress - Different CSS for Dropdown Menu

On my WordPress website I have used wp_nav_menu to create the navigation bar. Because of this I have limited control over the HTML, for one of the navigation links I have started styling it to be a dropdown. However, the CSS for the rest of the navigation bar is interfering with this, how can I modify the HTML so that I can separate the two?
HTML -
<nav class="site-nav">
<div class="menu-primary-menu-links-container"><ul id="menu-primary-menu-links" class="menu"><li id="menu-item-36" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-36">Contact</li>
<li id="menu-item-37" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-37">Tuition</li>
<li id="menu-item-38" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-28 current_page_item current_page_parent menu-item-38">Blog</li>
<li id="menu-item-107" class="test menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-107">Gallery
<ul class="sub-menu">
<li id="menu-item-119" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat menu-item-119">Animals</li>
<li id="menu-item-120" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat menu-item-120">Contemporary Space Images</li>
</ul>
</li>
<li id="menu-item-42" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home menu-item-42">Home</li>
</ul>

Highlighting correct path with Wordpress Nav_Menu function

I have created a WordPress site for a client, in which you filter through the navigation menu (set-up in appearance->menu) by revealing hidden items (unordered lists with class "sub-menu (generated through WordPress menu function)).
There are three hierarchal tiers; Pages>custom-links>Posts. When the page is clicked, the children (custom-links) are revealed, when a custom link is clicked, the children posts are revealed.
Then, when you are on a post, the path taken is highlighted in the navigation.
This is done through css and current/parent/ancestor classes generated with the wp_nav_menu function.
The mark-up generated by the wp_nav_menu function is this:
<ul id="menu-menu-2" class="main_menu"><li id="menu-item-155" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current_page_ancestor menu-item-has-children menu-item-155">Design
<ul class="sub-menu">
<li id="menu-item-152" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-ancestor current-menu-parent menu-item-has-children menu-item-152">#DesignCat1
<ul class="sub-menu">
<li id="menu-item-207" class="menu-item menu-item-type-post_type menu-item-object-post current-menu-item menu-item-207">DesignC1P1</li>
<li id="menu-item-206" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-206">DesignC1P2</li>
</ul>
</li>
<li id="menu-item-153" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-153">#DesignCat2
<ul class="sub-menu">
<li id="menu-item-144" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-144">DesignC2P1</li>
<li id="menu-item-143" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-143">DesignC2P2</li>
</ul>
</li>
</ul>
</li>
<li id="menu-item-156" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-156">Research
<ul class="sub-menu">
<li id="menu-item-149" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-149">#ResearchCat1
<ul class="sub-menu">
<li id="menu-item-205" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-205">ResearchC1P1</li>
<li id="menu-item-204" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-204">ResearchC1P2</li>
</ul>
</li>
<li id="menu-item-150" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-150">#ResearchCat2
<ul class="sub-menu">
<li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-140">ResearchC2P1</li>
<li id="menu-item-139" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-139">ResearchC2P2</li>
</ul>
</li>
</ul>
</li>
</ul>
The current page being "DesignC1P1", it's assigned a class of "current-menu-item", its parent (a custom link(#DesignCat1)) assigned "current-menu-parent" and its ancestor (a page(Design)) assigned "current-menu-ancestor". So, with CSS I do:
.current-menu-item > .sub-menu, .current-menu-parent > .sub-menu, .current-menu-ancestor > .sub-menu {
visibility: visible;
display: inline;
}
.current-menu-item > a, .current-menu-parent > a, .current-menu-ancestor > a {
color: #000;
text-decoration: none;
}
Which works well, it keeps all the relevant menu items visible and highlighted in black.
My issue is that my client has specifically asked for posts to be in more than one location in the menu, IE the same post could be under Design page and Research Page, or under two different custom-links in design/research. That means the same mark up is generated for the two item locations, and both paths are shown rather than the path taken. Here is what the generated code with the "Same Post" under #DesignCat1 and #ResearchCat1 would look like:
<ul id="menu-menu-2" class="main_menu"><li id="menu-item-155" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current_page_ancestor menu-item-has-children menu-item-155">Design
<ul class="sub-menu">
<li id="menu-item-152" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-ancestor current-menu-parent menu-item-has-children menu-item-152">#DesignCat1
<ul class="sub-menu">
<li id="menu-item-202" class="menu-item menu-item-type-post_type menu-item-object-post current-menu-item menu-item-202">Same Post</li>
</ul>
</li>
<li id="menu-item-153" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-153">#DesignCat2
<ul class="sub-menu">
<li id="menu-item-144" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-144">DesignC2P1</li>
<li id="menu-item-143" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-143">DesignC2P2</li>
</ul>
</li>
</ul>
</li>
<li id="menu-item-156" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current_page_ancestor menu-item-has-children menu-item-156">Research
<ul class="sub-menu">
<li id="menu-item-149" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-ancestor current-menu-parent menu-item-has-children menu-item-149">#ResearchCat1
<ul class="sub-menu">
<li id="menu-item-203" class="menu-item menu-item-type-post_type menu-item-object-post current-menu-item menu-item-203">Same Post</li>
</ul>
</li>
<li id="menu-item-150" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-150">#ResearchCat2
<ul class="sub-menu">
<li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-140">ResearchC2P1</li>
<li id="menu-item-139" class="menu-item menu-item-type-post_type menu-item-object-post menu-item-139">ResearchC2P2</li>
</ul>
</li>
</ul>
</li>
</ul>
Any ideas how to highlight only the path taken, rather than both? I know HTML,CSS and a bit of java, not so good with PHP! Any help would be greatly appreciated!

Display certain items of a WordPress menu

I generate a menu in Wordpress that has three layers. I do that with the code:
wp_nav_menu(array('theme_location' => 'primary', 'menu_class' => 'SecondaryNavigation'));
Wordpress generates a menu like this:
<div class="menu-mainnavigation_de-container">
<ul id="menu-mainnavigation_de" class="SecondaryNavigation">
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-39">
Home
<ul class="sub-menu">
<li id="menu-item-44" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-44">Einführung</li>
<li id="menu-item-43" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-43">Aktuelles</li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-30 current_page_item current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-has-children menu-item-40">
Der Tell
<ul class="sub-menu">
<li id="menu-item-42" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-30 current_page_item menu-item-42">Beschreibung</li>
<li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41">Topographie</li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-51">
Forschung
<ul class="sub-menu">
<li id="menu-item-53" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-53">Forschungsgeschichte</li>
<li id="menu-item-52" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-52">Forschungsprobleme</li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-65">
Kampagnen
<ul class="sub-menu">
<li id="menu-item-64" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-64">
Ausgrabung 2010
<ul class="sub-menu">
<li id="menu-item-63" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-63">Grabungsstelle C – Haus I (Sq. 6644-5, 6744-6 & 6844-6)</li>
</ul>
</li>
</ul>
</li>
</ul>
I have to divide the menu into two menues: In the header on the top, only the first layer of the menu is visible. This is very easy with the depth-call of wp_nav_menu and works just fine.
In the Sidebar I want to display the corresponding second and third level (everything under the class .sub-menu) of the menu, depending what was selected in the header. I tried to do this via CSS with the two simple lines:
.SecondaryNavigation {
display: none;
}
.SecondaryNavigation .current-menu-ancestor .sub-menu {
display: block;
}
Unfortunately, this does not work. How can I display only the second and third level of my menu, depending on what was selected in the primary level? Wordpress assigns the corresponding classes, like .current-menu-ancestor or .sub-menu, so it must be possible in some way, right?
Thanks for your help!
All the best
Sebastian
I would simply create the secondary menus and then list on the pages accordingly, which will be quite simple and effective.
Let me know if you need further help.

Wordpress Menus and using :first-letter

I am wanting to use :first-letter on the code below but I am unsure on the correct procedure or if possible can it be applied to <li>?
Code:
<div class="menu-left_menu-container">
<ul id="menu-left_menu" class="menu">
<li id="menu-item-3632" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-3632"><a href='http://#.co.nz/new'>Home</a> : </li>
<li id="menu-item-3705" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3705"><a href='http://#.co.nz/new/about-us/'>About Us</a> : </li>
<li id="menu-item-3702" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item current_page_item menu-item-3702"><a href='http://#.co.nz/new/shop/'>Shop</a> : </li>
</ul>
</div>
try this i think this is used full.
<div class="menu-left_menu-container">
<ul id="menu-left_menu" class="menu">
<li id="menu-item-3632" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-3632"><a href='http://#.co.nz/new'>Home</a> : </li>
<li id="menu-item-3705" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3705"><a href='http://#.co.nz/new/about-us/'>About Us</a> : </li>
<li id="menu-item-3702" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item current_page_item menu-item-3702"><a href='http://#.co.nz/new/shop/'>Shop</a> : </li>
</ul>
write css like this it is working.
#menu-left_menu > li::first-letter{
color:red;
}
below css is not working. above css is working.
#menu-left_menu > li > a::first-letter{
color:red;
}
According to the W3 spec, the :first-letter pseudo-element only work for a block element, which a is not.

Resources