I am tearing my hair out over this, I have a dropdown menu using CSS and jQuery (thanks to Soh Tanaka) and it works perfectly in Firefox, Safari, Google chrome and I.E. 8, but in IE 7 it will not drop down outside the 'Banner div'. It drops below the nav div however. I have moved the nav div higher in the banner the result is the same, menu drops until it reaches the border of the banner div and then vanishes....
Below is the css. This is my first website and I have some limited understanding of what I am doing. The drop down menu includes transparent png's as links (I know, I know...but it's what the Boss wants...) please could someone take a quick scan at the below CSS and let me know what is wroong? Is this some form of the IE z-index bug? i have tried all different combinations of z-index and still I can't get a different result. . The html is below as well.
I set all the z-indexes to 0 out of sheer frustration, I know it won't work as is.
Thankyou in advance
#banner {
position: relative;
width: 62.5em;
height: 12em;
background-color: #46280A;
background-image: url('images/includes/banner2.jpg');
background-repeat: no-repeat;
background-position: center;
-moz-box-shadow: -4px 6px 8px #000;
-webkit-box-shadow: -4px 6px 8px #000;
box-shadow: -4px 6px 8px #000;
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=8, Direction=225, Color='#000000')";
/* For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=8, Direction=225, Color='#000000');
z-index: 1;
}
/*------------------------------------SCROLLER---------------------------------------------*/
#headlines{
position: absolute;
top: 1.3em;
right: 2.75em;
overflow: hidden;
height: 2.5em;
width: 24em;
background-color: #000000;
display: block;
z-index: 3;
}
#news{
position: relative;
height: 3.1em;
line-height: 2.5em;
font-size: 0.8em
color: #FFFF99;
white-space: nowrap;
overflow: hidden;
font-family: Georgia,Arial;
}
#scrollerglass{
position: absolute;
top: 0.95em;
right: 2em;
height: 52px;
width: 410px;
border: none;
padding: 0.2em 0em 0em 0em;
line-height: 0.7em;
text-align: center;
background-image: url('images/includes/scrollerglass.png');
background-color: transparent;
background-repeat: no-repeat;
background-position: center;
opacity: 20;
z-index: 10;
}
#scrollerglass a i {
visibility: hiddn ;
}
/-------------------------------------NAVIGATION-----------------------------------------/
#nav {
position: absolute;
top: 5.8em;
left: 0.2em;
font-family: trebuchet, sans-serif;
font-size: 1em;
line-height: 3.75em;
text-align: center;
color: #FFFF00;
z-index: 3;
}
ul.navlist {
list-style: none;
padding: 0em;
margin: 1em;
float: left;
width: 62.5em;
background: transparent;
font-size: 1em;
}
ul.navlist li {
position: relative; /*--Declare X and Y axis base for sub navigation--*/
float: left;
margin: 0em 1.4em;
padding: 0em 0.7em 0em 0em;
z-index: 1;
}
ul.navlist li a{
display: block;
text-decoration: none;
float: left;
border: 0px solid;
}
ul.navlist li img{
border: 0px solid;
}
ul.navlist li span { trigger styles--*/
width: 1.2em;
height: 5.25em;
float: left;
background: url(images/links/downlogo.png) no-repeat center top;
}
ul.navlist li span.subhover { background-position: center bottom;
cursor: pointer;
}
ul.navlist li ul.navdrop {
list-style: none;
position: absolute;
float: left;
top: 5.3em;
left: -2.4em;
height: 15.0em;
width: 11.25em;
margin: 0;
padding: 0.5em 0em 0em 0em;
display: none; background-position: center;
background-image: url('images/includes/slider.jpg');
background-color: transparent;
background-repeat: no-repeat;
-moz-box-shadow: -4px 6px 8px #000;
-webkit-box-shadow: -4px 6px 8px #000;
box-shadow: -4px 6px 8px #000;
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=8, Direction=225, Color='#000000')";
/* For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=8, Direction=225, Color='#000000');
z-index:1;
}
ul.navlist li ul.navdrop li{
margin: 0em 2.3em 0em 0em;
padding: 1em 0em 0em 0em;
width: 8em;
clear: both;
}
html ul.navlist li ul.navdrop li a {
border: 0px solid;
width: 11.25em;
}
html ul.navlist li ul.navdrop li a:hover { background: transparent;
}
<div id="banner">
<div id="headlines">
<div id="news">
Whatever we want to promote
</div>
</div>
<div id="scrollerglass">
<a href="vintagecigars.php">
<i>------s-c-r-o-l-l-e-r - - - -l-i-n-k-s--------<br />
<br>------s-c-r-o-l-l-e-r - - - -l-i-n-k-s------</i></a>
</div>
<div id="nav">
<ul class="navmenu">
<li><img src="images/links/home.png" alt="Home" ></li>
<li><img src="images/links/ourbar.png" alt="Our Bar" >
<ul class="navdrop">
<li ><img src="images/links/cockteles.png" alt="Our Cocktails" ></li>
<li ><img src="images/links/celebrate.png" alt="Celebrate in Style" ></li>
</ul>
</li>
<li><img src="images/links/ourcigars.png" alt="Our Cigars" >
<ul class="navdrop">
<li ><img src="images/links/edicioneslimitadas.png" alt="Edition Limitadas" ></li>
<li ><img src="images/links/cigartasting.png" alt="Cigar Tastings" ></li>
</ul>
</li>
<li><img src="images/links/personalcigar.png" alt="Personal Cigar Roller" ></li>
<li><img src="images/links/photogallery.png" alt="Photo Gallery" ></li>
<li><img src="images/links/contactus.png" alt="Contact Us" ></li>
</ul></div></div><!--end banner-->
OK, I've fixed it. The answer is that the drop-down will not display over the 'filter' effect in IE. 7 and below.
Apologies to all you IE 7 users, but it's just not gonna look so pretty for you.
Another solution which I found for my dropdown menu is to add to the content Div z-index:-1;
I can't tell exactly whats going on just by your css, but I have had a similar problem and it woldn't let me hover unless the drop down section had a background color on it otherwise it would 'see through' it and lose the hover state. You could try that.
Please also view your HTML.
However, let's say this is your structure (simplified):
<div id="#nav">
<ul>
...
</ul>
</div>
<div id="content">
</div>
You have to verify, that #nav's z-index is bigger than that of #content. So:
#nav {
position:relative;
z-index:2;
}
#content {
position:relative;
z-index:1;
}
Don't forget, that z-index works only on the elements that have position other than static (default);
The idea is that parent of the element that is not shown (parent of the drop-down element), has to have z-index bigger, than the element that "overlaps" the drop-down.
You can read an excellent article on the subject here: http://aplus.rs/lab/z-pos/
Related
I am new in programming and I have a simple question: I want to make the words in this navigation bar be further from each other.
ul{
list-style-type: none;
margin: 0px;
padding: 0px;
width: 100%;
overflow: hidden;
top: 0;
position: fixed;
}
li{
float: right;
transform: translateX(-300px);
transform: translateY(-30px;);
}
li a{
display: block;
text-align:center;
padding: 12px 16px;
text-decoration: none;
color: #fff ;
font-size: 37px;
font-family: 'Alegreya', serif;
}
<div class="header">
<header class="title">CSS Tricks</header>
<ul>
<li>
Home
</li>
<li>
Contact
</li>
<li>
About
</li>
<li>
News
</li>
</ul>
</div>
I don't see the point of using transform.. use display: flex instead of float: right and if you would like to have it on the right side, do justify-content: flex-end. About your question, if it is having space between the <a> use the margin: 0 30px or if your meant between letters, do letter-spacing: 5px like in the example below..
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
overflow: hidden;
top: 0;
position: fixed;
display: flex;
}
li a {
display: block;
padding: 12px 0;
margin: 0 30px;
text-decoration: none;
color: #000;
font-size: 3em;
font-family: 'Alegreya', serif;
letter-spacing: 5px;
}
<div class="header">
<ul>
<li>Home</li>
<li>Contact</li>
<li>About</li>
<li>News</li>
</ul>
</div>
you have a typo on this property transform: translateY(-30px;);
it should be without ; after value -30px
👇
transform: translateY(-30px);
Currently you've got a padding of 16px on the sides of your hyperlink tags. Because it's on both the left and right sides, that adds up to 32px between the text of each. Increasing that value will increase the space between the links.
Adding padding or margin to the <li> elements would also work.
I am having issues with my mobile menu, it looks to be a z-index issue as when the menu is toggled, it appears behind the content below. However, I've been playing with this, and I can not get the toggled menu to the front.
Code:
HTML:
<section class="navigation">
<div class="nav-container">
<div class="brand">
<img class="header-image" src="assets/img/storey-and-co-logo.png" alt="Storey & Co. Solicitors" title="Storey & Co. Solicitors">
</div>
<nav>
<div class="nav-mobile">
<a id="nav-toggle" href="#!"><span></span></a>
</div>
<ul class="nav-list">
<li>
About Us
</li>
<li>
Our Team
</li>
<li>
Services
<ul class="nav-dropdown">
<li>
Divorce
</li>
<li>
Wills
</li>
<li>
Residential
</li>
</ul>
</li>
<li>
Contact
</li>
<li class="nav-highlight">
Obtain a Quote
</li>
</ul>
</nav>
</div>
</section>
Jquery
(function($) {
$(function() {
$('nav>ul>li').addEventListener('click',function() {
$(this).children('.nav-dropdown').show();
});
$('nav>ul>li').mouseleave(function() {
$('.nav-dropdown').hide();
});
});
document.querySelector('#nav-toggle').addEventListener('click', function() {
this.classList.toggle('active');
});
$('#nav-toggle').click(function() {
$('nav ul').toggle();
});
})(jQuery);
Sass
header
background: $brand-primary
height: $nav-height
clear: both
section.navigation
padding: 0px
clear: both
nav
float: right
ul
list-style: none
margin: 0
padding: 0
li
float: left
position: relative
a
display: block
padding: 0 20px
line-height: $nav-height
background: $brand-primary
color: #fff
text-decoration: none
&:hover
background: $brand-3-dark
color: #fff
&:not(:only-child):after
padding-left: 4px
content: ' â–¾'
ul li
min-width: 190px
& a
padding: 15px
line-height: 20px
z-index: 1
.nav-highlight a
background: $brand-3-dark
color: #fff
&:hover
background: $brand-3-primary
.nav-dropdown
position: absolute
display: none
z-index: 1
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15)
.nav-mobile
display: none
position: absolute
top: 0
right: 0
background: $brand-primary
height: $nav-height
width: $nav-height
#nav-toggle
position: relative
z-index: 9
left: 18px
top: 22px
cursor: pointer
padding: 10px 35px 16px 0px
span,
span:before,
span:after
cursor: pointer
border-radius: 1px
height: 5px
width: 35px
background: #fff
position: absolute
display: block
content: ''
transition: all 300ms ease-in-out
span:before
top: -10px
span:after
bottom: -10px
&.active span
background-color: transparent
&:before,
&:after
top: 0
&:before
transform: rotate(45deg)
&:after
transform: rotate(-45deg)
#media only screen and (max-width: $breakpoint)
.nav-mobile
display: block
nav
width: 100%
padding: $nav-height 0 15px
ul
display: none
li
float: none
a
padding: 15px
line-height: 20px
ul li a
padding-left: 30px
.nav-dropdown
position: static
#media screen and (min-width: $breakpoint)
.nav-list
display: block !important
.navigation
height: $nav-height
background: $brand-primary
.nav-container
max-width: $content-width
margin: 0 auto
.brand
position: absolute
float: left
padding-top: 10px
vertical-align: middle
text-transform: uppercase
font-size: 1.4em
box-sizing: border-box
a,
a:visited
color: #fff
text-decoration: none
img.header-image
max-width: 200px
#media screen and (max-width: $breakpoint-small)
img.header-image
max-width: 175px
padding-top: 10px
And the live version is here: http://staging-maris-storey.transitiongraphics.co.uk/
Help appreciated
Try adding a relative position and a higher z-index to your nav:
nav {
position: relative;
z-index: 9;
}
I'm not sure why Maggie Serino answer isn't working for you, because it work when I am testing it. However another solution would be to add clear:both; to the first section. The issue is being caused by your fixed height header, which is causing the section below not to be pushed down by the dropdown.
header + section {
clear:both;
}
#Grant Smith if you'd prefer the menu to cover the content you need to give it an absolute position (and the parent needs to be relative). I've tried a bit on your staging and you should add:
nav {
position: relative;
// your other attributes
}
.nav-list {
position: absolute;
width: 100%;
// your other attributes
}
Let me know if it worked.
When I'm hovering content inside div I'm getting offsets toward right side, I know that's because I'm adding left border, but how can I avoid this?
ul li:hover {
border-left: 4px solid #FF2F5A;
}
https://jsfiddle.net/eeeek/j8xaru7m/
While one can set a transparent border for the non-hovered state, that might sometimes given unwanted alignment.
Here is a solution using a pseudo element that overcomes that. The position: relative; on the ul li is necessary for the absolute positioned pseudo to position itself properly.
ul li {
position: relative; /* added property */
margin-left: -26px;
list-style-type: none;
width: 491px;
height: 50px;
border-bottom: 1px solid #F2F2F2;
}
ul li > span {
line-height: 40px;
margin-left: 30px;
}
ul li:hover::before { /* updated rule */
content: '';
position: absolute;
top: 0; left: 0; bottom: 0;
width: 4px; background: #FF2F5A;
}
.items {
position: absolute;
margin-left: -17.7px;
}
.block-with-items-style {
margin-left: 50px;
height: 400px;
width: 300px;
border: 2px solid #f2f2f2;
box-shadow: 2px 2px 10px #adadad;
resize: vertical;
overflow: hidden;
}
<div class="block-with-items-style">
<div class="items">
<ul>
<li ng-repeat="record in records">
<span>1</span>
<span class="badge badge-style">2</span>
<button class="delete" ng-click="Delete($index)">3</button>
</li>
</ul>
</div>
</div>
Bonus: This way one can easily add an animation as well
ul li {
position: relative; /* added property */
margin-left: -26px;
list-style-type: none;
width: 491px;
height: 50px;
border-bottom: 1px solid #F2F2F2;
}
ul li > span {
line-height: 40px;
margin-left: 30px;
}
ul li::before { /* added rule */
content: '';
position: absolute;
top: 50%; left: 0; bottom: 50%;
width: 4px; background: #FF2F5A;
transition: top .5s, bottom .5s;
}
ul li:hover::before { /* updated rule */
top: 0; bottom: 0;
}
.items {
position: absolute;
margin-left: -17.7px;
}
.block-with-items-style {
margin-left: 50px;
height: 400px;
width: 300px;
border: 2px solid #f2f2f2;
box-shadow: 2px 2px 10px #adadad;
resize: vertical;
overflow: hidden;
}
<div class="block-with-items-style">
<div class="items">
<ul>
<li ng-repeat="record in records">
<span>1</span>
<span class="badge badge-style">2</span>
<button class="delete" ng-click="Delete($index)">3</button>
</li>
</ul>
</div>
</div>
Just create invisible (100% alpha) border with previous css directive. As long hover is active – it will overwrite that transparent border with red. Here's the code:
ul li {
margin-left: -26px;
list-style-type: none;
width: 491px;
height: 50px;
border-bottom: 1px solid #F2F2F2;
}
ul li > span {
line-height: 40px;
margin-left: 30px;
}
/* Sylogista's upgrade begin */
ul li:not(:hover)
{
border-left: 4px solid rgba(255,255,255,0);
}
/* Sylogista's upgrade end */
ul li:hover {
border-left: 4px solid #FF2F5A;
}
.items {
position: absolute;
margin-left: -17.7px;
}
.block-with-items-style {
margin-left: 50px;
height: 400px;
width: 300px;
border: 2px solid #f2f2f2;
box-shadow: 2px 2px 10px #adadad;
resize: vertical;
overflow: hidden;
}
<div class="block-with-items-style">
<div class="items">
<ul>
<li ng-repeat="record in records">
<span>1</span>
<span class="badge badge-style">2</span>
<button class="delete" ng-click="Delete($index)">3</button>
</li>
</ul>
</div>
</div>
:not(:hover) is optional. Code will work good without it, but in my opinion – using that can be good practice. When? That's not place for debate, but let me give one short example in the margin of that answer: when you're creating huge css using many of states in that way and relations between elements – it just looks clearer.
In that case it's clearer maybe without it, but I'll not change that. Even just because of that not so many people use :not or even remember about that.
Please read my profile before proceeding. Anyone who doesn't keep the critique to only the code itself will be disregarded. Okay? Okay.
I'm trying to do tooltips to my navigation header, using the code on this page. The bottom tooltip, specifically.
I've snagged out the relevant parts of code from my own CSS and webpage to tool around with in their Try It Editor to get it working, and I've been cussing at this since last week and this is the furthest I've gotten to making it work, and even that came with some sacrifices in design I'm not sure how to fix. I will admit that tooltips like this are a very new area for me, and I'm trying to learn a new thing, and it's making me give it a very salty side-eye. So pointers to where I'm going wrong and what I need to be doing to correct it are what I'm looking for. Links to any sites that explain this better would also be tremendously appreciated.
<!DOCTYPE html>
<html>
<style>
body {
margin: 0px;
padding: 0;
background-color: #000000;
background-image: url(http://www.metathriving.com/img/index2bg.png);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #72809F;
}
/* Header */
#header {
width: 960px;
height: 160px;
margin: 0px auto;
background-color:rgba(0,0,0,0.5);
}
/* Boy Without A Fairy */
#navi {
float: left;
width: 900px;
height: 55px;
}
#navi ul li {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#navi a {
display: block;
float: left;
height: 45px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #578fa8;
}
#navi a:hover {
color: #9dd0ed;
}
#navi a.active {
color: #FFFFFF;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #c0c0c0;
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent #ffffff transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
<body>
<div id="header">
<!-- Hey! Listen! -->
<div id="navi">
<ul>
<li><span style="color:#c0c0c0; font-weight: bold;">Just Another<br>Brick in<br>the Wall</span></li>
<li><div class="tooltip">Weary Eyes Still<br>Stray to the<br>Horizon <span class="tooltiptext">More About Me</span><div></li>
<li><span style="font-style: italic;">A Heavenly Ride<br>Through<br>Our Silence</span></li>
<li><span style="font-style: italic;">A Thousand<br>Miles of<br>Moonlight Later</span></li>
<li><span style="font-style: italic;">Trade Your Heroes<br>For Ghosts</span></li>
<li><span style="font-style: italic;">If You Can Hear<br>This Whispering<br>You Are Dying</span></li>
<li><span style="font-style: italic;">I'll See You On<br>the Dark Side<br>of the Moon</span></li>
<li><span style="font-style: italic;">Frontiers Shift<br>Like<br>Desert Sands</span></li>
<li><span style="font-style: italic;">You Are Only<br>Coming Through<br>In Waves</span></li>
</ul>
</div>
</body>
</html>
Here's a screencap of what that code renders in the w3schools.com Tryit Editor panel. (Ignore the font colors and the fact it's not easy to see in some spots because of text + background. the font will be tweaked when I have the layout done, I change up font colors as I work to make sure things are working and to single out stuff. And the full code does give a solid background under the text for better legibility.)
Screencap of what the code makes
As you can see, it line breaks. Where it does, the tool tip works. But it's not supposed to move the rest of it to a new line. At least, I don't want it to do that. I'm not sure where it's going off the rails here. Like I said, this is a new trick I'm trying to learn and I'm stumped, after a week of working, research, and several books studying. It's right in front of me, and it's gotta be bloody obvious, but what IS it?
Two issues:
There were a few tags in the tooltip incorrectly wrapped. Namely, <a></span></a></span>. I corrected this.
Then, the tooltip is causing the break you don't want. Add a float: left; to the .tooltip class.
body {
margin: 0px;
padding: 0;
background-color: #000000;
background-image: url(http://www.metathriving.com/img/index2bg.png);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #72809F;
}
/* Header */
#header {
width: 960px;
height: 160px;
margin: 0px auto;
background-color: rgba(0, 0, 0, 0.5);
}
/* Boy Without A Fairy */
#navi {
float: left;
width: 900px;
height: 55px;
}
#navi ul li {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#navi a {
display: block;
float: left;
height: 45px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #578fa8;
}
#navi a:hover {
color: #9dd0ed;
}
#navi a.active {
color: #FFFFFF;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
float: left;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #c0c0c0;
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent #ffffff transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style> <body> <div id="header"> <!-- Hey! Listen! -->
<div id="navi">
<ul>
<li><span style="color:#c0c0c0; font-weight: bold;">Just Another<br>Brick in<br>the Wall</span>
</li>
<li>
<div class="tooltip"><a href="about.html">Weary Eyes Still<br>Stray to the<br>Horizon <span class="tooltiptext">More About Me
</span></a>
</div>
</li>
<li><span style="font-style: italic;">A Heavenly Ride<br>Through<br>Our Silence</span>
</li>
<li><span style="font-style: italic;">A Thousand<br>Miles of<br>Moonlight Later</span>
</li>
<li><span style="font-style: italic;">Trade Your Heroes<br>For Ghosts</span>
</li>
<li><span style="font-style: italic;">If You Can Hear<br>This Whispering<br>You Are Dying</span>
</li>
<li><span style="font-style: italic;">I'll See You On<br>the Dark Side<br>of the Moon</span>
</li>
<li><span style="font-style: italic;">Frontiers Shift<br>Like<br>Desert Sands</span>
</li>
<li><span style="font-style: italic;">You Are Only<br>Coming Through<br>In Waves</span>
</li>
</ul>
</div>
I'm trying to create a very basic page of weblinks, arranged into 7 columns. Some of the links have sub-links. What I want to happen is when the mouse is held over a link that has sub-links, the sub-links are to appear just below it and just to the right (as shown in menu 2.2)
I've cobbled the code together from various websites (I'm not a coder!), and I'm almost there I think, but if you take a look at the jsfiddle you will see there is a problem with the 3rd column (I've cut the menu down in the example).
HTML
<div id="container">
<ul id="menu">
<li><h3>Menu 1</h3></li>
<li>1.1</li>
<li>1.2</li>
</ul>
<ul id="menu">
<li><h3>Menu 2</h3></li>
<li>2.1</li>
<li>2.2
<ul id="sub1">
<li>2.2.1</li>
<li>2.2.2</li>
<li>2.2.3</li>
</ul>
</li>
</ul>
<ul id="menu">
<li><h3>Menu 3</h3></li>
<li>3.1
<ul id="sub2">
<li>3.1.1</li>
<li>3.1.2</li>
<li>3.1.3</li>
</ul>
</li>
<li>3.2</li>
<li>3.3</li>
</ul>
CSS
a {
font-family: arial, helvetica, sans-serif;
font-size: 12px;
font-weight: 700;
text-decoration:none;
color:black;
display:block;
padding-top: 17px;
padding-bottom: 17px;
outline: 0;
}
a:visited {
color:black;
background-color:#fff;
}
a:hover {
color:#fff;
background-color:#302403;
display:block;
}
ul {
padding: 10px 0px 0px 0px;
margin: 1px;
display: inline-block;
text-align: center;
position:relative;
list-style-type:none;
float: left;
width: 160px;
background-color: #fff;
height: 400px;
}
ul#sub1 {
position: relative;
left: 30px;
top: -15px;
visibility: hidden;
height: auto;
padding: 0;
}
ul#sub2 {
position: relative;
left: 30px;
top: -15px;
visibility: hidden;
height: auto;
padding: 0;
}
ul#menu li:hover #sub1 {
visibility: visible;
height: auto;
z-index: 1;
border: 2px solid;
padding: 0;
}
ul#menu li:hover #sub2 {
visibility: visible;
height: auto;
z-index: 1;
border: 2px solid;
padding: 0;
}
http://jsfiddle.net/87u27aw0/
I can get it to work if I give each sub-menu it's own absolute position, but I'm sure there is a better way than how I'm doing it - using relative maybe? Oh, and it has to work in IE8 onwards.
Thanks in advance.
Graybags