I've been trying to figure out a way to change the html structure of my web app using media queries so that my nav collapses into a drop down on the mobile site. It seems that the only way to change the actual markup is to use jquery, but I'd like to avoid that if possible.
I've looked all over but all of the suggestions ive tried online just cause more problems than it solves bc im using the materialize css framework for the site. Hopefully someone here has worked with materialize before and has solved the problem already.
Here is the html:
<nav class="nav">
<div class="nav-wrapper">
Game Swap
<ul id="nav-mobile" class="right">
<li><a id="homeMenu" href="#">Home</a></li>
<li><a id="searchMenu" href="#">Matches</a></li>
<li><a id="profileMenu" href="#">Profile</a></li>
<li><a id="loginMenu" href="#">Login</a></li>
<li><a id="logoutMenu" href="#">Logout</a></li>
</ul>
</div>
</nav>
As of now, the nav works pretty well as all res until you get to about 620px wide, then the nav items start overlapping the logo.
Here's the materialize documentation if helpful.
Thanks for any help in advance.
UPDATE: I have succesfully used materialize to replace my nav with a hamburger nav. However, when clicked on desktop, there is no dropdown. It has occurred to me that maybe this hamburger nav is merely a button for mobile for side navigation to animate from the side onto the screen. If not, then there is somethign else wrong with the code. The documentation claims there is an "example below" but I dont see it. See here: http://materializecss.com/navbar.html#mobile-collapse
I have also initialized the jquery line at the end of document ready, so that shouldnt be the issue.
updated HTML:
<nav class="nav">
<div class="nav-wrapper">
Game Swap
<i class="material-icons">menu</i>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a id="homeMenu" href="#">Home</a></li>
<li><a id="searchMenu" href="#">Matches</a></li>
<li><a id="profileMenu" href="#">Profile</a></li>
<li><a id="loginMenu" href="#">Login</a></li>
<li><a id="logoutMenu" href="#">Logout</a></li>
</ul>
<ul class="side-nav" id="mobile-demo">
<li><a id="homeMenu" href="#">Home</a></li>
<li><a id="searchMenu" href="#">Matches</a></li>
<li><a id="profileMenu" href="#">Profile</a></li>
<li><a id="loginMenu" href="#">Login</a></li>
<li><a id="logoutMenu" href="#">Logout</a></li>
</ul>
</div>
</nav>
UPDATE 2: I decided to make the whole thing a drop down, using a different component altogether. See solution below for anyone with the same issue.
<ul id="dropdown1" class="dropdown-content">
<li><a id="homeMenu" href="#">Home</a></li>
<li><a id="searchMenu" href="#">Matches</a></li>
<li><a id="profileMenu" href="#">Profile</a></li>
<li><a id="loginMenu" href="#">Login</a></li>
<li><a id="logoutMenu" href="#">Logout</a></li>
</ul>
<nav class="nav">
<div class="nav-wrapper">
Game Swap
<ul class="right">
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Menu<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
</div>
</nav>
Yes it is for mobile, and hidden in desktop view, but you can show it but changing the view to block from none, check the following code:
#media only screen and (min-width: 993px){
nav a.button-collapse {
display: block;
}
}
Originally the display of .button-collapse on(min-width: 993px) is none;
Check the codepen I created, this is working fine.
http://codepen.io/adrianrios/pen/xgWWRO
Related
HTML for Nav bar...
<nav id="navbar" class="navbar">
<ul>
<li><a class="nav-link scrollto active" href="#hero">Home</a></li>
<li><a class="nav-link scrollto" href="#about">About</a></li>
<li><a class="nav-link scrollto" href="#portfolio">The World</a></li>
<li><a class="nav-link scrollto" href="#journal">Journal</a></li>
<li><a class="nav-link scrollto" href="#contact">Contact</a></li>
</ul>
<i class="bi bi-list mobile-nav-toggle"></i>
</nav><!-- .navbar -->
Additionally, I have the sections I want using the id= tag. For example...
<div id="hero" name="hero" class="home">
<div id="about" class="paddsection">
<div id="portfolio" class="paddsection">
<div id="journal" class="paddsection">
<div id="contact" class="paddsection">
The strange part is that "hero", "services", and "portfolio" all work when I click them in the navbar. However, "journal" and "contact" just scroll to a location within the "portfolio" section. Additionally, if I manually type in #journal or #contact into the URL bar, then it works! I'm lost, please help!
Perhaps your browser's cache is full, try pressing ctrl + alt f5 to clear and update. Also try to test in another browser if possible.
hi friends i have issue with this code that when i clicked on any tab its not working ... i did not find any issue but still its not working so find solution for me. when i click on the tab it is not redirect to next page it will be in same page... please try to fix
<div class="navbar-collapse collapse">
<div class="menu">
<ul class="nav nav-tabs" role="tablist">
<li><a data-toggle="tab" href="index.html"
style="color:#8B008B;font-family: 'Autour One';"><b>Home</b>
</a></li>
<li><a data-toggle="tab" href="familytree.html"
style="color:#8B008B;font-family: 'Autour One';"><b>family
Tree</b></a></li>
<li><a data-toggle="tab" href="gallery.html"
style="color:#8B008B;font-family: 'Autour One';"><b>Gallery</b></a>
</li>
</ul>
</div>
</div>
You have to add the attribute target="_blank".
For instance:
<b>Home</b>
I'm relatively new to web development, and I'm using Materialize for the project I'm working on right now. My navbar code is attached, for some reason I can click on and follow the links in the sidebar, but not in the nav-content tabs. When I take out the tabs tabs-transparent classes in the ul, it works, but it looks ugly. I am loading JQuery- that was the only resolution I saw to this problem when I googled.
<nav class="blue-grey lighten-1 nav-extended" role="navigation">
<div class="nav-wrapper">
<a id="logo-container" href="#" class="brand-logo center"><img src="/application/static/application/colorondarknotext.png" height=60px/></a>
<ul class="right hide-on-med-and-down">
<li><a class="dropdown-button" href="#!" data-activates="dropdown1">Welcome, (USERNAME)!<i class="material-icons right">arrow_drop_down</i></a></li>
</ul>
<ul id="nav-mobile" class="side-nav">
<li class="no-padding">
<ul class="collapsible collapsible-accordion">
<li>
<a class="collapsible-header">Welcome, (USERNAME)!<i class="material-icons right">arrow_drop_down</i></a>
<div class="collapsible-body">
<ul>
<li>Account Info</li>
<li>Log Out</li>
</ul>
</div>
</li>
</ul>
</li>
<li>
<div class="divider"></div>
</li>
<li>Application</li>
<li>Decisions</li>
<li>Travel Information</li>
</ul>
<i class="material-icons">menu</i>
</div>
<div class="nav-content hide-on-med-and-down">
<ul class="tabs tabs-transparent">
<li class="tab">Application</li>
<li class="tab">Decisions</li>
<li class="tab">Travel Information</li>
</ul>
</div>
</nav>
I've run into a series of issues like this.
Generally you need to look deeper in the docs. In this case the navbar component docs don't address the issue in their example code. You need to look under javascript>tabs section of the docs to uncover more details about how the tabs work.
http://materializecss.com/tabs.html#external
By default, Materialize tabs will ignore their default anchor behaviour. To force a tab to behave as a regular hyperlink, just specify the target property of that link!
The normal anchor (<a>) functionality is disabled/ignored. In order to make your links work like "normal" you need to add a target attribute to your links.
Assuming you want to open the links in the same window, you would add target="_self" to each <a> tag.
<li class="tab">Application</li>
<li class="tab">Decisions</li>
<li class="tab">Travel Information</li>
With my HTML code I have created a dropdown menu within a tab. I need to add content to those individual "tabs" in the dropdown menu. I need help linking those together.
<div class="container">
<ul class="nav nav-tabs">
<li class="active tab_class" style="background: #009933"><a data-toggle="tab" href="#about">About</a></li>
<li class="dropdown">
<a class="dropdown-toggle" style="background: #009933" data-toggle="dropdown" href="#">Teaching
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Submenu 1-1</li>
<li>Submenu 1-2</li>
<li>Submenu 1-3</li>
</ul>
</li>
<li class = "tab_class" style="background: #009933"><a data-toggle="tab" href="#research">Research</a></li>
</ul>
</div>
This is currently what my code looks like creating the tabs. How can I correctly use classes and href to add content to each subtab within? I am thinking I may not have correctly made subtab's active, but i'm also not sure how to go about doing that. I am also using bootstrap within HTML and have that correctly imported.
Any help would be appreciated! Thanks
Following is the html which I am using:
<div class="fixed contain-to-grid">
<nav class="top-bar" data-topbar role="navigation">
<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="right">
<li>Home</li>
<li><a href="#photo">Photos</li>
<li><a href="#video">Videos</li>
<li><a href="#blog">Blog</li>
<li><a href="#contact">Contact</li>
</ul>
</section>
</nav>
</div>
By default, it looks like this:
Home Photos Videos Blog Contact
When I am decreasing the size of my browser, it works fine and at the smallest, it turns into a hamburger menu.
But when I increase the size back to normal, the li tags don't line up as usual.
They appear something like this:
Home Photos
Videos Blog
Contact
What am I doing wrong?
There are known responsive-issues with foundation's top-bar.
But your top-bar looks very simple. Could work for you.
First try if fixing your html-markup eliminates the problem. You have missing </a>-tags.
See:
<li><a href="#photo">Photos</li>
<li><a href="#video">Videos</li>
<li><a href="#blog">Blog</li>
<li><a href="#contact">Contact</li>