I'm working on a menu system that has a horizontal menu bar with pop-out menus when hovering over each of the options. What I would like to see happen is that when you hover over a menu option, there is no wrapping of top-level sub options. If I define a static width for this content it works, nothing wraps, but this looks poorly designed for the menus with less content as there's unnecessary white space. If I add a white-space nowrap the content no longer wraps but the "container" UL doesn't automatically size to the correct size of the content that is contained within it when inline-block formatted (this is the iteration that is linked below). I would like to go with a nowrap solution where the parent UL for each LI menu is sized automatically so that i don't enforce an over sized boundary that has excess white space.
The menu is below:
<div class="container">
<ul id="nav">
<li>Home</li>
<li>generic
<span id="s1"></span>
<ul class="subs">
<li>generic</li>
<li>generic 1
<ul>
<li>generic 1</li>
<li>generic 2</li>
<li>generic 3</li>
<li>generic 4</li>
<li>generic 5</li>
</ul>
</li>
<li>Week 2
<ul>
<li>Day 1</li>
<li>Day 2</li>
<li>Day 3</li>
<li>Day 4</li>
<li>Day 5</li>
</ul>
</li>
<li>Week 3</li>
<li>Week 4</li>
<li>Continual Education</li>
</ul>
</li>
<li>generic
<span id="s2"></span>
<ul class="subs">
<li>generic
<ul>
<li>generic</li>
<li>generic</li>
<li>generic</li>
</ul>
</li>
<li>Tech
<ul>
<li>generic</li>
<li>generic</li>
<li>generic</li>
<li>generic</li>
<li>generic</li>
<li>generic</li>
</ul>
</li>
<li>generic
</li>
<li>generic
</li>
</ul>
</li>
<li>generic
<span id="s3"></span>
<ul class="subs">
<li>generic</li>
<li>generic</li>
<li>generic</li>
<li>generic</li>
<li>generic</li>
</ul>
</li>
<li>generic
<span id="s4"></span>
<ul class="subs">
<li>generic
<ul>
<li>generic</li>
<li>generic</li>
<li>generic</li>
</ul>
</li>
<li>generic</li>
<li>generic</li>
</ul>
</li>
<li>generic</li>
<li>generic/generic/generic</li>
<li>generic
<span id="s5"></span>
<ul class="subs">
<li>generic</li>
</ul>
</li>
</ul>
</div>
I'm linking the whole project via JSFidle because it's just too much to put here and there's linked content. Make note in the running version in JSFiddle that when you hover over a menu the black border (which is the box, in the final version it will just be a basic drop shadow) in most of the sub menus is smaller than the content - this is what I'm trying to solve.
JSFiddle Project
If you can help I greatly appreciate it!
Didn't find an answer here that matches quite my scenario, but have tried to consider answers for similar questions - to no avail.
In your #nav ul.subs > li class, you are setting side padding relatively with %.
Changing this to absolute value in px has fixed the problem - saved to your fiddle.
Related
I've got a simple drop down menu like this:
<nav>
<ul class="nav">
<li class="topmenu"> Grp 1
<ul id="firstul">
<li class="submenu">Example 1</li>
<li class="submenu">Example 2</li>
</ul>
</li>
<li class="topmenu"> Grp 2
<ul id="secondul">
<li class="submenu">Example 1</li>
<li class="submenu">Example 2</li>
</ul>
</li>
</ul>
</nav>
Now it happens, that sometimes, if I click f.e. on the first li in the firstul "Example 1" (which should lead to https://www.example/grp1/exmpl1.php) it loads the "Example 1" of the seconduland I dont find the mistake why. It appears completly random. Sometimes on the first click, sometimes after a few. Can somebody give me a hint why this happens?
I am trying to write my article beside my vertical menu, but all my article going inside that menu. I want my menu to be fixed on that page on the left side and all my new articles or any pictures should come on after menu.
MY HTML
<nav id="wrapper-250">
<ul class="accordion">
<li id="one" class="files">
Health Beat
<ul class="sub-menu">
<li><em>01</em>Sub Menu 1
<ul class="sub-sub-menu">
<li><em>a</em>Sub Menu 2</li>
<li><em>b</em>Sub Menu 2</li>
<li><em>c</em>Sub Menu 2</li>
<li><em>d</em>Sub Menu 2</li>
<li><em>e</em>Sub Menu 2</li>
</ul>
</li>
<li><em>02</em>Sub Menu 1</li>
<li><em>03</em>Sub Menu 1</li>
<li><em>04</em>Sub Menu 1</li>
<li><em>05</em>Sub Menu 1</li>
</ul>
</li>
<li id="two" class="mail">
Mail
<ul class="sub-menu">
<li><em>01</em>Hotmail</li>
<li><em>02</em>Yahoo</li>
</ul>
</li>
<li id="three" class="cloud">
Cloud
<ul class="sub-menu">
<li><em>01</em>Connect</li>
<li><em>02</em>Profiles</li>
<li><em>03</em>Options</li>
<li><em>04</em>Connect</li>
<li><em>05</em>Profiles</li>
<li><em>06</em>Options</li>
</ul>
</li>
<li id="four" class="sign">
Sign Out
<ul class="sub-menu">
<li><em>01</em>Log Out</li>
<li><em>02</em>Delete Account</li>
<li><em>03</em>Freeze Account</li>
</ul>
</li>
</ul>
</nav>
<div id="body-part">
<p>
</P>
</div>
http://codepen.io/anon/pen/XbXbqQ
Add a big padding-left to your #body-part:
padding-left: 500px; /* example */
Demo here: http://jsfiddle.net/baLq1d1k/
Or you can do it using jquery if the width of your #wrapper-250 changes:
$("#body-part").css("padding-left", ($("#wrapper-250").width() + 10));
I am trying to create an appropriate semantic markup for header section of design below.
Please header section of this bootstrap theme (Sorry i couldn't add image due to reputation restriction)
Please see code below
<header role="banner">
Skip to main content
<div class="utility-bar">
<ul>
<li><span>Mail</span>
</li>
<li><span>Number</span>
</li>
</ul>
<ul>
<li><span>Social Link 1</span>
</li>
<li><span>Social Link 2</span>
</li>
<li><span>Social Link 3</span>
</li>
<li><span>Social Link 4</span>
</li>
<li><span>Social Link 5</span>
</li>
</ul>
</div>
<a href="#">
<img src="img/logo.svg">
</a>
<nav role="navigation">
<ul>
<li>
Main 1
<ul>
<li>SubMenu 1
</li>
<li>SubMenu 2
</li>
<li>SubMenu 3
</li>
<li>SubMenu 4
</li>
<li>SubMenu 5
</li>
</ul>
</li>
<li>Main 2</li>
<li>Main 3</li>
<li>Main 4</li>
<li>Main 5</li>
<li>Main 6</li>
</ul>
<button title="Show / Hide menu">
<img src="burger.png" alt="Show / Hide menu">
</button>
</nav>
</header>
From reading articles about semantics in sites like HTML5Doctor and posts in stackoverflow. I have the following doubts.
Where should we place the "utility bar"/ "Top Bar", which contains
the social links and contact details? Should we place it in aside
outside the header tag, as it is tangential content to the site.
Is the trick of using H1 for logo with text-indent, not advised
anymore?
Where should we place the burger icon for responsive view. Some doesn't place it in the markup , but add it using javascript. It is the recommended way. if we place it in markup, where is the appropriate place.
I have a menu structure, like this:
<nav id="main">
<ul id="nav-user">
<li class="user-name">
<span class="name">John Doe</span>
<ul class="submenu">
<li>Profile</li>
<li>Settings</li>
<li>Sign Out</li>
</ul>
</li>
</ul>
<ul id="nav-main">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
</nav>
I'm having an issue with ul.submenu. It's overlaying ul#nav-main, but for some reason it's transparent:
http://jsfiddle.net/JvALU/
I don't want to see the ul#nav-main. How can I change that?
z-index can only be used with elements that are positioned relative, absolute, or fixed. Try adding position: relative; to ul.submenu.
Hope this helps.
How can I make the menu-category color attribute change to orange when hovered and NOT remain orange while hovering other child items? Is this too tricky or am I not being clear enough? Please let me know. Thank you for help.
jsFiddle: http://jsfiddle.net/LmWk2/
<nav class="main-nav">
<ul>
<li class="menu-category">Title 1
<ul>
<li class="menu-item">Item 1</li>
<li class="menu-item">Item 2</li>
<li class="menu-item">Item 3</li>
<li class="menu-item">Item 4</li>
</ul>
</li>
<li class="menu-category">Title 2
<ul>
<li class="menu-item">Item 1</li>
<li class="menu-item">Item 2</li>
<li class="menu-item">Item 3</li>
<li class="menu-item">Item 4</li>
<li class="menu-item">Item 5</li>
</ul>
</li>
<li class="menu-category">Title 3
<ul>
<li class="menu-item">Item 1</li>
<li class="menu-item">Item 2</li>
<li class="menu-item">Item 3</li>
<li class="menu-item">Item 4</li>
<li class="menu-item">Item 5</li>
</ul>
</li>
<li class="menu-category">Title 4
<ul>
<li class="menu-item">Item 1</li>
<li class="menu-item">Item 2</li>
<li class="menu-item">Item 3</li>
<li class="menu-item">Item 4</li>
</ul>
</li>
</ul>
</nav>
The simplest way would be to add another element that wraps only the title:
<li class="menu-category"><span class="menu-category-title">Title 1</span>
.menu-category-title:hover {
color: orange;
}
http://jsfiddle.net/ExplosionPIlls/LmWk2/1/ (for TITLE1)
My answer addresses the color-change-on-hover issue and the related issue of making the links behave like buttons (block like) instead of text links.
As pointed out by a previous post, it is a good idea to wrap the title tag in a container, I chose h4 but almost anything will do. Also, for semantic reasons, but the link tags inside the list-item tags:
<nav class="main-nav">
<ul>
<li class="menu-category"><h4>Title 1</h4>
<ul>
<li class="menu-item">Item 1</li>
<li class="menu-item">Item 2</li>
<li class="menu-item">Item 3</li>
<li class="menu-item">Item 4</li>
</ul>
</li>
...
...
...
</ul>
</nav>
The essential changes to the CSS are as follows.
For the title text:
.main-nav ul li.menu-category h4 {
margin: 0;
display: inline-block;
padding:5px 15px 8px 15px;
font-weight: normal;
}
.main-nav ul li.menu-category h4:hover {
color:#FB8521;
}
The trick here is to set display: inline-block to the element wrapping the title text. Because I chose to use h4, I needed to zero out the margin and set the font-weight to normal to keep with your previous styling. Also, add padding to make the text area large so you can trigger the hover effect without actually mousing over the text.
For the sub-menu items, set the a tags to have display: block, that way the link's active area fills up the width of the sub-menu panel. Add padding as needed.
.menu-category .menu-item a {
display: block;
padding: 5px 15px;
}
.menu-category .menu-item a:hover {
color:#FB8521;
}
You can see the working demo at: http://jsfiddle.net/audetwebdesign/jvgkG/
PS
There is flexibility in this layout with regards to how the hover works. I assumed that the title text reverts to white when you mouse onto the secondary menu items, but I could set it up so that the title remains orange as you move over the secondary menu.
Also, you can style the default link color as you see fit.