IE7 Subnav, two positioning issues - css

Site in question: http://khill.mhostiuckproductions.com/siteLSSBoilerPlate/
If you test the above link in IE7 (I am using IE9 with browsermode and browser compatability for IE7), there is a positioning problem with the subnavs.
Hover over about us, then hover over home, and then go back to About us. You will see the sub-nav has moved to the right by the width of the LI above it.
This is coded purely in CSS. This works perfectly in all browsers except for IE7, I would like to keep this working within CSS, without any Javascript fixes.
I also have a z-index issue, any ideas on these two issues?
Here is the CSS code that handles the main UL and LI, as well as the CSS that handles the first Subnav. (note the secondary subnav under "Michael" works as intended).
***Note that the class .main-nav is applied to the first UL that handles the horizontal bar. The class .main-sub-nav is applied to the UL that holds the subnav LI's Michael, Kenny etc. under the About us menu.
nav .main-nav {
position: absolute; /* allows us to absolute position the subnavs */
display: block;
width: 100%;
height: 40px; /*height of inner nav for white border */
padding: 0;
margin: 0;
border: 1px solid #fff; /* Inner white border */
-moz-border-radius: 5px; /*rounded edges */
-webkit-border-radius: 5px;
border-radius: 5px;
}
nav ul > li {
display: inline-block;
height: 40px;
padding: 0;
margin: 0 0 0 -4px;
}
/* MAIN NAV SUBNAV STYLES */
.main-sub-nav { /* BASIC STYLING PLUS HIDE */
position: absolute;
display: none;
z-index: 1;
width: 200px;
height: auto;
top: 100%;
border: 1px solid #d4d4d4;
background: #f6f6f6;
}
nav ul > li:hover > .main-sub-nav { /* ON HOVER MAKE SUB-NAV VISIBLE */
display: block;
}
nav ul li .main-sub-nav li {
position: relative;
height: 40px;
display: block;
padding: 0;
margin: 0;
border-top: 1px solid #fff;
border-right: none;
border-bottom: 1px solid #f2f2f2;
border-left: 1px solid #fff;
}

The thing is that you are incorrectly using positioning.
Try this approach. I have commented few changes.
.row.margin-bottom-15.nav-container { /* Remove overflow:hidden; so your dropdowns will be shown when they overflow. */}
nav .main-nav {
/* removed position:absolute; */
display: block;
width: 100%;
height: 40px;
padding: 0;
margin: 0;
border: 1px solid #fff;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
nav ul > li {
position: relative; /* Add position:relative; so you can absolute position dropdowns */
display: inline-block;
height: 40px;
padding: 0;
margin: 0 0 0 -4px;
}
.main-sub-nav {
position: absolute;
display: none;
z-index: 1;
width: 200px;
height: auto;
top: 100%;
left: 0;
border: 1px solid #d4d4d4;
background: #f6f6f6;
}
nav ul > li:hover > .main-sub-nav {
display: block;
}
nav ul li .main-sub-nav li {
position: relative;
height: 40px;
display: block;
padding: 0;
margin: 0;
border-top: 1px solid #fff;
border-right: none;
border-bottom: 1px solid #f2f2f2;
border-left: 1px solid #fff;
}
Let me know if it helped.

Related

Why doesn't css code for a dropdown menu's box-shadow work in ul li ul{}, but in ul li:hover ul{}?

It's css for a dropdown menu's box-shadow. I can't figure out why it doesn't work in line 56, but works in line 45. It seems the editor knows why. Do you know why?
line 56 box-shadow is lighter, and it doesn't work
nav ul li:hover ul{
display: block;
box-shadow: 2px 2px 5px purple;
}
nav ul li ul{
margin-left: 3rem;
position: absolute;
z-index: 999;
display: none;
width: 10rem;
text-align: left;
background-color: hotpink;
border-radius: 5px
box-shadow: 2px 2px 5px purple;
}
You can use my dropdown menu, it works for me:
.drop{
display: inline-block;
position: relative;
}
.pop{
display: none;
position:fixed;
z-index: 1;
padding: 0;
margin: auto;
min-height: fit-content;
min-width: fit-content;
background-color: orangered;
list-style-type: none;
}
.drop:hover .pop{
display: block;
}
just add you own code.
i hope this is useful.

CSS: <a> tags disabled after using pseudo elements

I'm doing a CSS exercise wherein the old BBC's site is to be cloned. The original problem was that the white bottom borders of the #topmenu li's appeared wonky (I included this code in the page below as a comment)
That has been fixed by adding the right red border using pseudo elements. However, the anchor tags have been disabled. I think it's due to the red border's "absolute" position, but I can't get the menu to appear as it should without the absolute position. Now, it looks how I want it, but the top menu links don't work anymore: http://jsbin.com/poginowibe/1/edit?output
Any ideas on how this can get sorted out? Any help would be appreciated.
/* This is the original code when the white bottom borders appeared weird */
#topmenudiv li {
list-style: none;
height: 100%;
padding: 14px 15px 11px 15px;
border-right: 1px solid #990800;
float: left;
position: relative;
z-index: 1;
}
#topmenudiv li:hover {
color: #ffffff;
text-decoration: none;
padding: 14px 15px 8px 15px;
border-bottom: 3px solid #FFFFFF;
outline: 0;
}
/* This is the code after the wonky appearance is fixed but the tags were disabled */
#topmenudiv li {
list-style: none;
height: 100%;
padding: 14px 15px 11px 15px;
float: left;
position: relative;
z-index: 1;
}
#topmenudiv li:hover {
color: #ffffff;
text-decoration: none;
padding: 14px 15px 8px 15px;
border-bottom: 3px solid #FFFFFF;
outline: 0;
}
#topmenudiv li::after {
content: "";
position: absolute;
bottom: 0; top: 0; left: 0; right: 0;
border-right: 1px solid #990800;
}
With some tweaks to Joerg's code, I was finally able to make it work!
#topmenudiv ul {
margin-top: 0px;
padding: 0;
}
#topmenudiv li {
list-style: none;
height: 38px;
line-height: 40px;
float: left;
position: relative;
z-index: 3;
}
#topmenudiv li:hover {
color: #ffffff;
text-decoration: none;
border-bottom: 3px solid #FFFFFF;
outline: 0;
}
#topmenudiv li a {
height: 100% !important;
font-size: 1em;
line-height: 40px;
border-right: 1px solid #990800;
display: block;
padding-left: 15px;
padding-right: 15px;
}
#topmenudiv li a:hover {
text-decoration: none;
}
Thanks a bunch! :)
Remove the #topmenudiv li::after from your css and change #topmenudiv li in this way:
#topmenudiv li {
list-style: none;
height: 100%;
padding: 14px 15px 11px 15px;
float: left;
position: relative;
z-index: 1;
border-right: 1px solid #990800;
}
Update
Use this code and see the remarks below:
#topmenudiv ul {
height: 40px;
margin: 0;
padding: 0;
}
#topmenudiv li {
list-style: none;
height: 40px;
float: left;
border-bottom: 3px solid #FFFFFF;
}
#topmenudiv li:hover {
color: #ffffff;
text-decoration: none;
border-bottom: 3px solid blue;
outline: 0;
}
#topmenudiv li a {
height: 40px !important;
font-size: 1em;
line-height: 40px;
border-right: 1px solid #990800;
display: block;
padding-left: 15px;
padding-right: 15px;
}
#topmenudiv li a:hover {
text-decoration: none;
}
Remove all your topmenudiv stuff in CSS, also this one above the comments.
I made the border-bottom line for hovering blue, so you can see that it works.
You are using an image on the right site of the topbar, #sphere. This should be an background-image in CSS, so you have not to handle with z-index and then the rest of the links will work.
What I have done is, give the a tags some height and line-height and bind the red border-left to it. I also removed some paddings and margins.

CSS hr tag in a nav bar with a margin

How do I add a rule above and below my nav bar? I tried an HR tag, but that seemed to make a lot of space around the nav bar. Here is my html and here is the example of how I want to do it.
http://matthewtbrown.com/jeffandcricketquilt/
http://matthewtbrown.com/jeffandcricketquilt/rule.png
If you do not want to change your html at all, you can add this to your css
nav ul:before {
border-bottom: 1px solid white;
border-top: 1px solid white;
bottom: 5px;
content: "";
left: 5px;
position: absolute;
right: 5px;
top: 5px;
z-index:0;
}
nav ul {
overflow: auto;
position: relative;
background-color:#000;
}
nav ul li{
position:relative;
z-index:10;
}
and remove the background-color from the li elements (since i added it to the ul)
Use borders and padding:
* {
margin: 0;
padding: 0;
}
nav {
text-align: center;
background: black;
color: white;
padding: .2em;
}
ul {
padding: .5em;
border: 1px solid white;
border-left: none;
border-right: none;
}
nav li {
display: inline;
list-style-type: none;
padding: 0 2em;
}
Demo
I would apply an outline to the ul tag, so the css should be:
nav ul{
outline-color: white;
outline-style: solid;
outline-width: 2px;
outline-offset: -7px;
height: 60px;
width: 848px;
}
Try applying this CSS to the nav bar:
border-top: 1px solid #eee
border-bottom: 1px solid #eee
The easiest is to add a padding to the nav element, 4px makes good with width of li elements. Also add float: left
Now add border-top and border-bottom to the ul element. Add float: left here as well. This will switch your li element around as they have a fixed width. lower the width of them to 210px and things should be fine.
CSS additions to your code:
nav {
padding: 4px
float: left;
}
nav ul {
border-top: 1px solid white;
border-bottom: 1px solid white;
float: left;
}
nav li {
width: 210px;
}
If line-height is the same as font-size you can manipulate border distance by changing padding-bottom of list element, here is my example:
.headerSection ul.navigation li a {
font-size: 12px;
line-height: 12px;
text-decoration: none ;
padding-bottom: 10px;
border-bottom-color: transparent;
border-bottom-width: 5px;
border-bottom-style: solid;
}
.headerSection ul.navigation li a:hover {
border-bottom-color: #e8bf5d;
}

CSS Horizontal Menu has wrong x-position, how to put directly under parent menu?

I'm trying to build a horizontal drop down menu with CSS. But the submenu appears either at the complete left of the site (when I set it to position: absolute) or to the very left of the menu (when set to position: relative). I want it to appear directly below the menu I hover on.
Here's my code:
/* div für Menü */
.menu{
height: 35px;
float: left;
padding: 0px;
margin: 0px;
outline: 1px solid grey;
background-color: #f6f6f6;
font-size:100%;
}
/* UL Menü */
.menu ul{
list-style: none;
margin: 0px;
padding: 0px;
float: left;
height: 100%;
background-color: #f6f6f6;
}
/* Untermenü anzeigen bei Mouseover */
.menu ul li:hover ul{
display: block;
}
/* Hintergrund ändern bei Mouseover */
.menu ul li:hover{
background-color: #005ea2;
}
/* Menü LI */
.menu ul li{
display: inline;
height: 35px;
padding-left: 5px;
padding-right: 5px;
padding-top: 9px;
padding-bottom: 9px;
margin: 0;
position: relative;
border-right: 1px dashed gray;
}
/* Letzter Eintrag ohne Rand */
.menu li:last-child{
border: none;
}
.menu a{
line-height: 250%;
color: #333333;
text-decoration: none;
height: 100%;
margin: 0px;
}
/* UL Untermenü */
.menu ul li ul{
display: none;
width: 200px;
padding: 0px;
margin: 0;
background-color: #f6f6f6;
outline: 1px solid gray;
position: absolute;
z-index: 200;
}
/* LI Untermenü */
.menu ul li ul li{
height: 35px;
display: block;
line-height: 100%;
padding: 0px;
border: none;
background-color: #f6f6f6;
position: relative;
}
Add here
.menu ul li:hover{
background-color: #005ea2;
}
a position: relative;.
This will establish a containing block in order to be able to position stuff relative to it. After that you can just fiddle with different top and left values to get the exact desired result.
Also the z-index on .menu ul li ul is useless.
On a separate note: Welcome to StackOverflow!

Double border effect with navigation?

I did this before but I can't remember how to do it again.
Image of what i'm trying to get:
and what I have so far
In between each link,, theres two borders. yes I know how to make the effect, put two borders together. But the problem is I can't do it!
At first I tried Jefferey ways Technic.
nav ul li:before { border-left: 1px solid red; content: ''; margin: 0 -30px; position: absolute; height: 20px; }
nav ul li:after { border-right: 1px solid white; content: ''; margin: 0 39px; position: absolute; height: 20px; }
It worked, except the borders from the left and right end of the nav is sticking out. I tried :first-of-type and :last-of-type to try to remove the borders at the end, but they didn't go away.
Then, I tried just using both :first-of-type and :last-of-type to create the borders,but again. it didn't work. So I don't really know what to do to create the effect! I wish there was a way to remove the front and end borders with Jefferey Ways code but I can't. Can anybody help?
Heres the whole css of the nav.
nav { background: #282828 url(../images/nav-bg.png) repeat-x; border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px; -o-border-radius: 6px; margin: 24px auto; padding: 11px 29px; width: 670px; }
nav ul {}
nav ul li { display: inline; padding: 32px; margin: 0 auto; }
nav ul li:before { border-right: 1px solid red; }
nav ul li:odd { border-right: 1px solid white; }
nav ul li a { color: #626262; height: 20px; }
#nav {
background: #282828 url(../images/nav-bg.png) repeat-x;
border-radius: 6px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
-o-border-radius: 6px;
margin: 24px auto;
padding: 11px 29px;
width: 670px; }
#nav ul { list-style: none; padding: 0; margin: 0;}
#nav ul li {
display: inline;
padding: 32px;
margin: 0 auto;
border-left: 1px solid #LIGHTERCOLOR;
border-right: 1px solid #DARKERCOLOR;
}
#nav ul li:first-child { border-left: 0; }
#nav ul li a { color: #626262; height: 20px; }
But I would suggest you cut out the separator as an image and put it on li as
background: transparent url(border-image.png) left center no-repeat;
and on the li:first-child have
background: none;

Resources