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.
Related
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;}
I have a horizontal navigation, and I want the last two item to be pushed to the right side of the container.
With only one item, I could simply float the last item of the navigation. But I want to apply this to two elements - and I have the constraint that their order has to be the same in HTML and for the viewer.
I tried the following, but this broke my javascript code which relies on
$('... a').parent().next().doSomething(...)
The code
<ul class="main main-nav">
<li class="first">Projekte</li>
<li>Aktuell</li>
<div class="push-right">
<li>Über uns</li>
<li>Kurse</li>
</div>
</ul>
Is there some obvious solution I don't see?
Any other shortcut?
You shouldn't place a div inside of a ul:
<ul class="main main-nav">
<li class="first">Projekte</li>
<li>Aktuell</li>
<li class="push-right">Über uns</li>
<li class="push-right">Kurse</li>
<!-- Or Flip them to maintain order -->
<li class="push-right">Kurse</li>
<li class="push-right">Über uns</li>
</ul>
CSS:
.push-right{
float:right;
}
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.
I am trying to get my head around Zurb Foundation's Top Navigation bar. I struggled to get it working first time around when I was including the navigation mark-up via a js include. When I copied the code into each html page it suddenly worked. This was fine, but I have added a new section to my site where the pages are dynamically formed with ruby.
The actual issue is that when a screen is small, the drop-down menu at the top right of the page stops working.
On the front page of my site, the navigation works on a small screen: Mac Media Production home page, however on this page: Mac Media Production Hosting page, the navigation bar no longer operates correctly, and as far as I am aware the mark-up is the same:
<!-- Header and Nav -->
<nav class="top-bar">
<ul>
<!-- Title Area -->
<li class="name">
<h1>
<a href="http://www.mac-media.co.uk">
mac media
</a>
</h1>
</li>
<li class="toggle-topbar"></li>
</ul>
<section>
<!-- Top Right Nav Section -->
<ul class="right">
<li class="has-dropdown">
<a class="active" href="http://www.mac-media.co.uk/index.html">Menu</a>
<ul class="dropdown">
<li><label>Pages</label></li>
<li>Home</li>
<li>Contact Us</li>
<li class="divider"></li>
<li><label>Our Services</label></li>
<li>Web Design</li>
<li>Photo</li>
<li>Video</li>
<li>Hosting</li>
<li>Emails</li>
<li>Domain Names</li>
<li class="divider"></li>
<li><label>Existing Clients</label></li>
<li>Control Panel</li>
<li>Webmail Login</li>
</ul>
</li>
<li class="divider hide-for-small"></li>
</ul>
</section>
</nav>
Can anyone help please!?
In ZURB Foundation 3, this line:
<li class="toggle-topbar"></li>
should be changed to:
<li class="toggle-topbar"></li>
This is just a placeholder for jQuery
Official Docs: http://foundation.zurb.com/old-docs/f3/navigation.php
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.