After wasting the whole day in efforts i am still not able to set the position of third level Menu. It shows always on top.
This is the Link of fiddle. Please suggest the change.
Piece of Html
<nav id="menu-main">
<ul id="menu">
<li class="item-132 deeper parent">Services
<ul>
<li class="item-132">Retail Banking
<ul>
<li class="levelThreeAlign">Sub sub menu</li>
</ul>
</li>
<li class="item-132">Types of Loans
<ul>
<li>Sub sub menu</li>
</ul></li>
</ul>
</li>
</ul>
</nav>
Whole CSS and HTML in Fiddle.
JS Fiddle
Your Problem is fixed
.item-132{ position : relative;}
Related
I have a a navigation with a sub navigation which is hidden by default, and I want to show the sub nav for each item on click, but currently on click it shows the subnav for all items at once since the click is toggling a class. How can I only toggle the subnav of the clicked item?
HTML
<nav class="st-menu" id="menu-4a">
<ul>
<li>
Guidance Manual
</li>
<li>
Resource Directory<div class="toggle-arrow"><img src="/assets/images/chevron-up-solid.svg"/></div>
<ul class="reg-subnav">
<li>Stormwater Plan Review Resources</li>
<li>Pilot Projects</li>
<li>Proprietary Products</li>
<li>Additional Resources</li>
</ul>
</li>
<li>
Stormwater 101<div class="toggle-arrow"><img src="/assets/images/chevron-up-solid.svg"/></div>
<ul class="reg-subnav">
<li>Regulations</li>
<li>Stormwater Management</li>
<li>Stormwater Billing & Retrofits</li>
<li>Green City, Clean Waters</li>
</ul>
</li>
<li>
Contact Us<div class="toggle-arrow"><img src="/assets/images/chevron-up-solid.svg"/></div>
<ul class="reg-subnav">
<li>About Us</li>
<li>Development Review Contacts</li>
</ul>
</li>
</ul>
</nav>
jQuery
$(".toggle-arrow").click(function(){
$(".reg-subnav").toggleClass('open-sub');
});
$(".toggle-arrow").click(function(){
$(this).closest('li').find(".reg-subnav").toggleClass('open-sub');
});
Both the arrow and the element you want to toggle, belong to an <li>. You can find the closest parent li that owns both of them, then find the element you want to toggle.
I'm using SASS, which I'm brand new to, but I'm running into problems. From the documentation, it sounded like I needed to edit _top-bar.scss and add a line that says: $topbar-menu-icon-position: $default-float; (as opposed to $opposite-direction;).
But that doesn't seem to work -- the hamburger menu icon continues to be right aligned on mobile.
I'm pretty sure the issue isn't with the HTML code, but just in case:
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1>Name</h1>
</li>
<li class="toggle-topbar menu-icon">
<span>menu</span>
</li>
</ul>
<section class="top-bar-section">
<ul class="left">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</section>
</nav>
If you look here
you will see a top bar position
$topbar-menu-icon-position: $opposite-direction !default; // Change to $default-float for a left menu icon
essentially you need to change it to
$topbar-menu-icon-position: $default-float !default;
I suggest adding that to your local sass and not edit the original file so that you can easily upgrade in the future.
I am using the Zurb Foundation 4 framework for my site. I want to have a navbar that is positioned beneath a header that sticks to the top of the page when you scroll past. This works fine, except that the page content jumps up ~45 pixels when the Top Bar sticks to the top of the page. The effect can be seen on this page, though this is a different navigation element: http://foundation.zurb.com/docs/components/magellan.html
Is there some way to fix this, or do I have to change my site design to accomodate this bug?
The documentation is here: http://foundation.zurb.com/docs/components/top-bar.html
<div class="contain-to-grid sticky">
<nav class="top-bar">
<ul class="title-area">
<!-- Title Area -->
<li class="name">
<h1>Top Bar</h1>
</li>
<!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<ul class="left">
<li class="divider"></li>
<li class="has-dropdown">Item 1
<ul class="dropdown">
<li><label>Level One</label></li>
<li>Sub-item 1</li>
<li>Sub-item 2</li>
<li class="divider"></li>
<li>Sub-item 3</li>
<li class="has-dropdown">Sub-item 4
<ul class="dropdown">
<li><label>Level Two</label></li>
<li class="has-dropdown">Sub-item 1
<ul class="dropdown">
<li><label>Level Three</label></li>
<li class="has-dropdown">Sub-item 1
<ul class="dropdown">
<li><label>Level Four</label></li>
<li>Sub-item 1</li>
</ul>
</li>
<li>Sub-item 2</li>
<li>Sub-item 3</li>
<li class="divider"></li>
<li>Sub-item 4</li>
</ul>
</li>
<li>Sub-item 2</li>
<li>Sub-item 3</li>
<li>Sub-item 4
</ul>
</li>
<li>Sub-item 5</li>
</ul>
</li>
<li class="divider"></li>
</ul>
<!-- Right Nav Section -->
<ul class="right">
<li class="divider hide-for-small"></li>
<li>Item 2</li>
</ul>
</section>
</nav>
This appears to be a hard-coded "feature" in Foundation 4's Javascript. Instead of merely preventing the default behavior of the link, it automatically forces the link to redirect to #, which causes the browser to jump to the top of the page. This appears to be intentional (more on that in a second).
The only alternative for now is to just not use the Top Bar component and create your own navigation using other, more reliable Foundation components. For instance, you can build your own navigation easily enough using both the .sticky class and simply defining a fresh <nav> element with all necessary <ul> menu items within.
The Top Bar has a very specific use by design... clicking "Menu" will use Javascript to reveal the navigation as a single column of options under the Top Bar. To ensure that mobile users can scroll a big set of options, this jumps the window to the top of the page and removes the fixed behavior until you close the menu. This works well enough when your Top Bar starts at the top of the page, but has serious implications when it doesn't (for instance, scrolling to the top of the page might move the menu out of view).
Now, this is purely opinion... but I'm really not a fan of Foundation's Top Bar implementation. Usability tests have shown that putting your mobile menus in the footer and linking to them with an anchor are more efficacious and user-friendly. You can use .hide-for-small to hide your desktop menu items and .show-for-small to reveal your own custom, anchored "Menu" link... that menu link would anchor to a mobile-specific menu in your footer (which again, you would reveal with .show-for-small).
Long story short: Top Bar is sloppy from a usability standpoint and broken (by design) for your use-case. I'd recommend building your own sticky menu :-)
This issue was fixed: https://github.com/zurb/foundation/issues/1993
Answer:
If you don't want it to jump to the top specify in data-options:
<nav class="top-bar" data-options="scrolltop: false">
or on initialization:
$(document).foundation('topbar', {scrolltop: false});
Remove the "sticky" class if you don't need it. Worked for me.
On this page: https://github.com/jordanmerrick/foundation/commit/47391710c7b6d30ad54e50f3b2526cb8f6184be1
I found the code in foundation.topbar.js that adds padding to the body tag depending on whether top-bar is sticky or not:
if ($('.sticky').length > 0) {
var distance = $('.sticky').length ? $('.sticky').offset().top: 0,
$window = $(window);
var offst = $('nav.top-bar').outerHeight()+20;
(".sticky").after("<div class='top-bar-sticky-padding'></div>");
$window.scroll(function() {
if ( $window.scrollTop() >= ( distance ) ) {
$(".sticky").addClass("fixed");
- $('body').css('padding-top',offst);
}
else if ( $window.scrollTop() < distance ) {
$(".sticky").removeClass("fixed");
- $('body').css('padding-top','0');
}
});
}
I'm not a javascript wizard - but it seems as if instead of setting offst to the height of the .top-bar, you set it to the value of .top-bar-sticky-padding directly, you can control the offset with a media query instead of forcing an offset the size of the top-bar.
Am I wrong? I'm nervous about "hacking core" but this seems to have solved the problem for me.
the page in question is http://www.streetstyles4all.co.uk/test4.html (general menu drop down problem)
Hi
I have decided to update my menu to use icons. I had a drop down menu working with no java script etc just css and html, and I tried to put icons beside each link in the drop down, but before I could go any further I could not get passed this problem, and get rid of the hover image that is used for the main navigation. The image appears next to every menu
I can't get passed this. Can anyone please advise.
My menu code is:
<ul id="menu">
<li id="home">Home</li>
<li id="general">General
<div class="dropdown_4columns">
<div class="col_1">
<h3>Street Styles 4 All</h3>
<ul id="submenu">
<li id="ss4aaboutus">About Us</li>
<li id="ss4aagency">Agency</li>
</ul>
</div>
<div class="col_1">
<h3>Events</h3>
<ul>
<li>What's on next</li>
<li>Competitions</li>
<li>End of Year Show</li>
<li>Summer School</li>
<li>Master Classes</li>
</ul>
</div>
<div class="col_1">
<h3>Dance Crew</h3>
<ul>
<li>Demo Squad</li>
<li>Pure Skillz</li>
<li>Performance Dates</li>
<li>How to Join</li>
</ul>
</div>
<div class="col_1">
<h3>Dance Crew</h3>
<ul>
<li>Demo Squad</li>
<li>Pure Skillz</li>
<li>Performance Dates</li>
<li>How to Join</li>
</ul>
</div>
</div>
</li>
<li id="nearestclass">Nearest Class</li>
<li id="tutorials">Tutorials</li>
<li id="shop">Shop</li>
<li id="hireus">Hire Us</li>
<li id="contact">Contact</li>
the page in question is http://www.streetstyles4all.co.uk/test4.html
I think the hover state and the height for #general is getting applied to the LI elements that are inside the #general LI element. You may need to define a class for the inner LI elements and set the background as none and mark it !important.
Try using the css z-index property for your images. As easy as z-index: 3;
Or try resizing the images also with css.
The following menu works really fine in the browser, but I cant get it to validate as XHTML. I took this example out of my CSS Book. It says it is right, but seemingly it is not.
<ul id="leftNavi">
<li>
left menu1
</li>
<li class="SCNL">left menu2</li>
<ul id="subnavi">
<li>
menu2/1
</li>
<li>
menu2/2
</li>
<li>
menu2/3
<li>
</ul>
<li>
left menu3
</li>
</ul>
Here a link to the page: http://www.yiip.de/arbeit/testlayout/standard_template.html I am talking about the left menu.
<ul id="leftNavi">
<li >left menu1</li>
<li class="SCNL">left menu2
<ul id="subnavi">
<li>menu2/1</li>
<li>menu2/2</li>
<li>menu2/3</li>
</ul>
</li>
<li>left menu3</li>
</ul>
You had a couple of problems:
The line with 3 as the list item didn't have a correct closing <li> element; and
The subnav1 list wasn't contained within a <li> element. It can't be a direct child of another list, which was the main problem with validating your HTML.