Ie7 dropdown menu hover over issue - css

Got an issue in ie7!, see the image below for how the dropdown menu looks. This works fine in every other browser but in ie7, as soon as you venture outside of the main li 'i.e.: the top link' the menu dissapears. I have already checked setting red boxes around everything and the li element is extending correctly to contain the sub menu but I cannot fix it. Any ideas?
Example of markup:
<nav>
<ul class="clearfix">
<li class="dropdown-link">Top Link
<ul class="clearfix dropdown-holder">
<li>
<div class="arrow"></div>
<div class="dropdown-holder-inner">
<ul class="dropdown">
<li>Link</li>
<li>Link</li>
<li>Linky</li>
<li>Link</li>
<li>Link</li>
<li class="last-child">Link</li>
</ul>
</div>
</li>
</ul>
</li>
</ul>
</nav>​
CSS is quite heavy so I have put the Full Code on jsfiddle: http://jsfiddle.net/n2kgX/3/
image: http://i.stack.imgur.com/k24Du.png

I create a sample here: http://jsfiddle.net/jho1086/bbULV/5/, I change the html code and css a little bit because in my opinion container are too many. And I change the HTML5 tag (<nav>) because IE8 and below is not supported with HTML5, unless you have a fixed.
<div id="nav">
<ul class="clearfix sf-menu">
<li class="dropdown-link">Top Link
<div class="clearfix dropdown-holder">
<div class="arrow"></div>
<ul class="dropdown clearfix">
<li>Link</li>
<li>Link</li>
<li>Linky</li>
<li>Link</li>
<li>Link</li>
<li class="last-child">Link</li>
</ul>
</div>
</li>
</ul>
</div>
css
#nav { background:#6B6C6E; width:300px; margin:30px auto 0;}
.sf-menu li{float:left; font:12px/1em 'arial'; position:relative; padding:0 0 5px;}
.sf-menu li a{float:left;padding:12px 10px 5px;color:#fff; text-transform:uppercase;}
.sf-menu .dropdown-holder{
position:absolute;
left:-999em;
width:218px;
top:93%;
}
.sf-menu li:hover .dropdown-holder {left:-999em;}
.sf-menu li:hover .dropdown-holder {left:0;}
.arrow { background:url(arrow.png) no-repeat left top; width:32px; height:8px; position:relative; z-index:2; left:10px;}
.dropdown {
box-shadow:0 0 5px #bec2c8;
background:#fff;
height:100%;
position:relative;
z-index:1;
padding:10px 10px 5px;
}
.sf-menu .dropdown li{text-transform:capitalize; border-bottom:1px solid #ccc;}
.sf-menu .dropdown li.last-child { border:0;}
.sf-menu .dropdown a{
float:left;
padding:5px 0;
width:198px;
color:#333;
}​​
Hope it helps.

I have a feeling that Your example is overcomplicated.
This is the simplest implementation of nested menu (with hover) I know of:
<ul class="outer">
<li>
<p>TOP MENU</p>
<ul class="inner">
<li>link1</li>
<li>link2
<ul class="inner">
<li>link2.1</li>
</ul>
</li>
<li>link3</li>
</ul>
</li>
</ul>
With a little bit of css:
.outer {
border: 1px solid red;
width: 100px;
}
.inner {
display: none;
}
.inner li {
padding: 0 0 0 10px;
}
.outer li:hover > .inner {
display: block;
}
Tested on IE8 (in IE7 mode with IE7 Standards). Check here: http://jsfiddle.net/BUuyV/11/

Here is what you can do:
<!--[if lte IE 7]>
<style type="text/css">
nav ul li:first-child ul.dropdown-holder{
left: 0px;
top:-4px;
}
</style>
<![endif]-->
Note: For :first-child to work in IE8 and earlier, a <!DOCTYPE> must be declared.

Related

Hover and focus not working on mobile dropdown menu options

On mobile here, I have a dropdown menu that comes down with some options in it. I would like these links to change color to grey when one "hovers" on it with the thumb on the phone. I haven't managed though I have tried several options as you can see in the code. This is it:
<div class="total">
<ul class="nav navbar-nav" >
<li>
<div class="id"><a style="width:100px" data-toggle="dropdown" href="#"><img src="grey.png" alt="Friends in class" class="barimage"> <span ></span></a>
<ul class="dropdown-menu">
<div class="dropdown">
<li><p><b>Search your friends</b> </p>
</li>
<li><p class="menupar"><b>My Friends </b></p>
</li>
<li><p class="menupar"><b>My account</b></p>
</li>
<li><p class="menupar"><b>Logout</b></p>
</li>
</div>
</ul>
</div>
</li>
and this is the CSS:
.dropdown {
margin-top:-3px;
width: 200px;
height:220px;
background-color: rgba(36, 96, 70, 1);
font-size:20px;
line-height:50px;
border-radius: 3px;
}
.menunav {
width: 200px;
height:80px;
color:green;
font-size:20px;
line-height:50px;
border:solid black;
border-radius:1px;
}
a:link {color:white;}
a:visited {color:white}
a:hover.menunav {background-color:grey;}
a:active.menunav {background-color:grey;}
a:focus.menunav {background-color:grey;}
a.menunav {
display: block;
height: 100%;
width: 100%;
text-decoration: none;
}
Not really sure why you'd want a hover effect on a mobile device, but using :focus whenever you use :hover should do the trick.

how to make a drop down menu fixed from the top with css?

I want to make a drop menu like the one in http://www.homeshop18.com/ with css only without jquery in particular the All category menu.I have tried css drop down menu but the problem is i am unable to fix the second level menu at the top. any suggestion will be appreciated.
Can't understand what you problem is from the way you posted the question but here is a quick menu I put together that only uses CSS that functions like the menu on the site you posted.
HTML:
<ul class="main">
<li>all
<ul class="sub">
<li>books
<ul class="sub2">
<li>fiction</li>
<li>biography</li>
</ul>
</li>
<li>mobile
<ul class="sub2">
<li>android</li>
<li>cmda</li>
<li>battery</li>
</ul>
</li>
</ul>
</li>
</ul>​
CSS:
li {
border:1px solid;
padding:1px;
}
.main {
list-style:none;
position:relative;
}
.sub, .sub2 {
list-style:none;
position:absolute;
display:none;
width:75px;
}
.sub2 {
float:left;
left:75px;
top:0px;
}
.main li:hover .sub,
.sub li:hover .sub2{
display:block;
}

Create tabbed rectangle with CSS

Is anybody aware of any CSS tricks that can achieve the tabbed rectangle look as shown in the image below.
Obviously this cannot be achieved using one div, however, can anybody come up with a better method than overlapping one div over another to make a gap in the border?
This is my current solution, but I feel it could be better:
HTML:
<div id="handle"></div>
<div id="menu"></div>
CSS (Have ignored colors and positioning etc):
#handle {
width: 90px;
height: 20px;
border-left: 1px solid #666;
border-right: 1px solid #666;
}
#menu {
width: 600px;
height: 100px;
border: 1px solid #666;
margin-top: 19px; /* Notice it is one pixel higher then the bottom of the #handle, this covers the top border where the handle is */
}
Please do not correct the above CSS if there are mistakes, I have not tested this. It is purely to show my current method of achieving this
Any comments much appreciated
UPDATE
This is the HTML for the menu as it stands:
<nav id="global-nav">
<ul>
<li id="homNav"></li>
<li id="masNav">#
<!-- This is where the submenu starts -->
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
<!-- This is where the submenu ends -->
</li>
<li id="shiNav">#
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
</li>
<li id="repNav">#
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
</li>
<li id="setNav">#
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
</li>
</ul>
</nav>
This is the CSS for the menu as it stands (I have not included the sub menu css yet):
/* Navigation */
#global-nav {position:absolute;width:460px;height:27px;left:15px;top:43px;}
#global-nav ul {margin:0;padding:0;list-style-type:none;}
#global-nav ul li {position:relative;display:block;width:92px;height:27px;float:left;padding:0;margin-left:8px;z-index:10;cursor:pointer;background-image:url("http://beta.example.net/_images/_global/sprite.png");background-position:-173px -32px;}
#global-nav ul li:hover {background-position:-173px -59px;}
#global-nav ul li:active {background-position:-173px -86px;}
#global-nav ul li a {display:block;width:92px;height:27px;line-height:27px;text-align:center;color:#fff;font-size:12px;text-shadow:#666 0 -1px 0;}
#global-nav ul li:hover a {color:#666;text-shadow:#fff 0 1px 0;}
#global-nav ul li:active a {color:#666;text-shadow:none;}
/* Set styles for specific navigation buttons */
#homNav {width:47px !important;margin-left:0 !important;margin-right:12px;background-position:-126px -32px !important;}
#homNav a {width:47px !important;}
#homNav:hover {background-position:-126px -59px !important;}
#homNav:active {background-position:-126px -86px !important;}
/* Set hovers of sub menu buttons to active images */
#masNav:hover,
#shiNav:hover,
#repNav:hover,
#setNav:hover
{background-position:-173px -86px !important;}
After having a good look at this I concluded that my original method of overlaying the border was the best way to achieve this tabbed menu.
HTML:
<nav id="global-nav">
<ul>
<li id="homNav"></li>
<li id="masNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
<li id="shiNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
<li id="repNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
<li id="setNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
</ul>
</nav>
CSS (Sorry for the compression, just my way of formatting):
/* Navigation */
#global-nav {position:absolute;width:460px;height:27px;left:15px;top:43px;}
#global-nav ul {margin:0;padding:0;list-style-type:none;}
#global-nav ul li {position:relative;display:block;width:92px;height:27px;float:left;padding:0;margin-left:8px;z-index:10;background-image:url("http://beta.example.net/_images/_global/sprite.png");background-position:-173px -32px;}
#global-nav ul li:hover {background-position:-173px -59px;}
#global-nav ul li:active {background-position:-173px -86px;}
#global-nav ul li a {display:block;width:92px;height:27px;line-height:27px;text-align:center;color:#fff;font-size:12px;text-shadow:#666 0 -1px 0;}
#global-nav ul li:hover a {color:#666;text-shadow:#fff 0 1px 0;}
#global-nav ul li:active a {color:#666;text-shadow:none;}
/* Set styles for specific navigation buttons */
#homNav {width:47px !important;margin-left:0 !important;margin-right:12px;background-position:-126px -32px !important;}
#homNav a {width:47px !important;}
#homNav:hover {background-position:-126px -59px !important;}
#homNav:active {background-position:-126px -86px !important;}
/* Set hovers of sub menu buttons to active images */
#masNav:hover,
#shiNav:hover,
#repNav:hover,
#setNav:hover
{background-position:-173px -86px !important;}
/* Set the sub menu handles */
#global-nav .subMenuHandle {position:relative;display:none;width:90px;height:12px;margin-top:-1px;border-left:1px solid #666;border-right:1px solid #666;z-index:1000;background-color:#fff;background-repeat:repeat-x;}
/* Set the sub menu container */
#global-nav .subMenu {position:relative;display:none;margin-top:-1px;width:910px;height:180px;border:1px solid #666;z-index:999;background-color:#ddd;background-position:0 -12px;background-repeat:repeat-x;}
/* Set the menu hovers to show sub menus */
#global-nav ul li:hover .subMenuHandle,
#global-nav ul li:hover .subMenu
{display:block;}
/* Set the sub menu container positions */
#masNav .subMenu {margin-left:-83px;}
#shiNav .subMenu {margin-left:-183px;}
#repNav .subMenu {margin-left:-283px;}
#setNav .subMenu {margin-left:-383px;}
/* Set the noise in the menus */
.bg-noise {position:absolute;left:0;top:0;width:100%;height:100%;background:url("https://www.beta.net/_images/_global/bg-noise.png") repeat;}

navbars shifted when compatibility view toggled

When I toggle IE9's Compatibility VIEW on/off, my navbar shifts positions:
When Compatibility View: ON:
navbar is centred fine. :)
When Compatibility View: OFF:
navbar is shifted to the right slightly. :(
NOTE: I could NOT attach a screenshot due to certain site restrictions. :(
Obviously I would like to correct this, but cannot; thus, why I am posting here. :)
My CSS file looks as follows:
/*background image for outside area*/
#outside {
background-image:url('/images/body_bg.gif');
}
/*style for main area*/
#main {
font:16px "Trebuchet MS", arial, verdana, serif, monospace;
margin-left:auto;
margin-right:auto;
width:1020px;
border:5px outset darkgrey;
background-color:white;
}
/*background image*/
#bg {
background-image:url('/images/content_bg.gif');
}
/*horizontal list item widths*/
ul.two li{width:50%;}
ul.four li{width:25%;}
ul.five li{width:20%;}
/*submenu list item widths*/
ul.sfour li a{width:25em;} /*alternate value = 19.1em*/
ul.sfive li a{width:18.5em;} /*alternate value = 15.3em*/
/*top navigation bar*/
#topnav ul {
list-style-type:none;
margin-left:auto;
margin-right:auto;
width:100%;
overflow:hidden;
}
#topnav li {
float:left;
}
#topnav li a {
background-color:#606060;
color:white;
display:block;
font-size:large;
font-weight:bold;
font-variant:small-caps;
padding-top:4px;
padding-bottom:4px;
text-align:center;
text-decoration:none;
}
#topnav li a:active {
color:yellow;
}
#topnav li a:hover {
background-color:#888888;
}
/*topnav submenus*/
#topnav li ul {
display:none;
position:absolute;
}
#topnav li:hover ul {
display:block;
}
#topnav li:hover li {
float:none;
}
#topnav li:hover a {
background-color:#888888;
}
#topnav li:hover li a {
display:block;
font-size:small;
font-weight:normal;
font-variant:normal;
text-align:center;
text-decoration:none;
}
#topnav li:hover li a:hover {
background-color:#B0B0B0
}
/*page title*/
h1 {
border-bottom:3px solid black;
color:gray;
margin-left:auto;
margin-right:auto;
width:90%;
}
/*content*/
#content {
margin-left:auto;
margin-right:auto;
width:90%;
}
My _Layout.cshtml file is as follows:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>C4DP - #Page.Title</title>
<link href="#Href("~/Styles/Style.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/scripts/functions.js"></script>
<script type="text/javascript" src="/scripts/sorttable.js"></script>
</head>
<body id="outside">
<div id="main">
<img src="/images/title_c4dp.gif" alt="C4DP" width="100%"/>
<div id="bg">
<div id="topnav">#RenderPage("~/navbar_Top.cshtml")</div>
<h1>#Page.Title</h1>
<div id="content">
#RenderBody()
</div>
<div id="bottomnav">#RenderPage("~/navbar_Bottom.cshtml")</div>
</div>
<p id="copyright">© 2012 C4DP. All rights reserved.</p>
</div>
</body>
</html>
The navbar file looks as follows:
#if (WebSecurity.IsAuthenticated) {
if (!Roles.IsUserInRole("admin")) {
<ul class="four">
<li>News</li>
<li>Stats
<ul class="sfour">
<li>Earnings</li>
<li>Session Average</li>
<li>Ranking</li>
</ul>
</li>
<li>Profile
<ul class="sfour">
<li>Personal Info.</li>
<li>Change Password</li>
</ul>
</li>
<li>Logout</li>
</ul>
} else { //logged in as administrator
<ul class="five">
<li>News</li>
<li>Stats
<ul class="sfive">
<li>Earnings</li>
<li>Session Average</li>
<li>Ranking</li>
</ul>
</li>
<li>Admin
<ul class="sfive">
<li>Cardrooms</li>
<li>Events</li>
<li>Members</li>
</ul>
</li>
<li>Profile
<ul class="sfive">
<li>Personal Info.</li>
<li>Change Password</li>
</ul>
</li>
<li>Logout</li>
</ul>
}
} else {
// nav bar when NOT logged in
<ul class="four">
<li>Home</li>
<li>Rules</li>
<li>Login</li>
<li>Request Membership</li>
</ul>
}
Please help!
It turns out that my navbar needed the {display:inline;} and {padding:0;} attributes added to it to make it work.
Not being a real guru at this stuff, I assume the INLINE attribute prevented it from being "pushed over" by its neighbouring element, and that the PADDING:0; attribute ensured that the navbar fit properly in its parent element.
If a "real guru" (someone with more experience than me) could confirm my assumption, that would be much appreciated. Thank you in advance.

How to fix <ul>'s in footer that break in ie8 & ie9, but is perfect in ie7, FF, Safari & Chrome

I'm having one hell of a headache trying to figure this out for myself, i've taught myself the code i know, so i very well could be missing a simple thing. But i greatly need you're help and appreciate it tremendously.
I obviously want my website to look the same across all browsers and this is a major mess, that i am struggling with.
The problem is easier to explain with pictures, as such i have a screen print from ie9 and ff to show you:
Firefox, Safari, Chrome & IE7
How the footer and lists look in Firefox, Safari, Chrome & IE7
IE9 & IE8 (the grey at the bottom is the body background)
How the footer and lists look in IE9 & IE8
Here is the html:
<div id="footer">
<div id="columncon">
<div class="column">
<h5>From The Blog...</h5>
<ul>
<li><a href="#">Blog Post 1<a/></li>
<li><a href="#">Blog Post 2<a/></li>
<li><a href="#">Blog Post 3<a/></li>
<li><a href="#">Blog Post 4<a/></li>
<li><a href="#">Blog Post 5<a/></li>
</ul>
</div>
<div class="column">
<h5>Social</h5>
<ul>
<li><a href="#">Facebook<a/></li>
<li><a href="#">Twitter<a/></li>
<li><a href="#">Google +<a/></li>
<li><a href="#">RSS Subscribe<a/></li>
<li><a href="#">E-mail Subscribe<a/></li>
</ul>
</div>
<div class="column">
<h5>Site Links</h5>
<ul>
<li><a href="#">Designer Resources<a/></li>
<li><a href="#">Submit a T-Shirt<a/></li>
<li><a href="#">Sitemap<a/></li>
<li><a href="#">Contact Us<a/></li>
</ul>
</div>
<div class="column">
<h5>Site Links</h5>
<ul>
<li><a href="#">Designer Resources<a/></li>
<li><a href="#">Submit a T-Shirt<a/></li>
<li><a href="#">Sitemap<a/></li>
<li><a href="#">Contact Us<a/></li>
</ul>
</div>
</div>
<div id="siteinfo">
<p>© 2011 TShirtSlut.com</p>
</div>
Here is the CSS:
#footer {
background: url(img/footerbg.png) 0 0;
-moz-box-shadow: 0 0px 10px #000;
-webkit-box-shadow: 0 0px 10px #000;
box-shadow: 0 0 10px #000;
height:200px;
position:relative;
clear:both;
}
#columncon {
width:1000px;
margin:0 auto;
}
.column {
float:left;
padding: 30px 25px 20px;
width: 200px;
}
.column ul {
list-style:none;
}
.column ul li {
padding:2px 0;
}
.column ul li a{
text-decoration:none;
color:#fff;
font-size:12px;
}
.column ul li a:hover{
color:#49E20E;
}
.column h5 {
padding-bottom:10px;
border-bottom:1px solid #fff;
color:#fff; text-shadow: black 0.1em 0.1em 0.2em;
font-weight:bold;
font-size:14px;
}
#siteinfo {
text-align:center;
width:100%;
margin:auto;
position:absolute;
bottom:0;
color:#fff;
font-size:12px;
}
#siteinfo a {
text-decoration:none;
color:#fff;
}
#siteinfo a:hover {
color:#49E20E;
text-decoration:none;
}
(apparently I'm not the best at inserting code XD)
Once again i truly will appreciate whoever can put this problem into context for me and allow me to solve this issue.
If you need anymore code, or info please ask and i shall get to it right away.
Thank you,
Mike
UPDATE: I have fixed the anchor tags so they validate but am still left with a double footer and the heading of the first list still remaining in the "doubled" footer. Please follow URL for a picture:
--http://tshirtslut.com/ie%28partially%20fixed%29.jpg--
Your html is not valid. Replace all <a/> with </a>. Is your problem solved now?

Resources