• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

Cross-Browser Problem with Overflow Hidden Preventing Menu Expansion

I enclose a horizontal javascript menu in a couple of divs to center them in a fluid layout.

I can get FF3 and IE7 to display the same way, with the use of overflow = hidden in the outermost div containing the menu (in this case div id="naverbarwrap") but overflow= hidden prevents the menu item from expanding vertically downwards.

Removing overflow= hidden fixes the menu expansion problem in both IE7 and FF3 and doesn't affect the page layout in IE7 but it breaks the layout in FF3.

Code and illustrative screengrabs in both IE7 and FF3 are attached.  The missing Javascript files and CSS are stock files from Dreamveaver CS3.

Is there a way to fix this in CSS without resorting to a conditional stylesheet being loaded in the html?

Thx


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>menutest2</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="CSS/global_reset_meyer.css" rel="stylesheet" type="text/css" />
<style>
/*import oneColElsCtr.css*/
body {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	background: #666666;
	margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
	padding: 0;
	text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
	color: #000000;
}
#container {
	/*	width: 46em;*/
 	width: 55em; /*update the container width set in oneColElsCtr.css by changing width=43em to width =55em*/
	background: #FFFFFF;
	margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
	border: 1px solid #000000;
	text-align: left; /* this overrides the text-align: center on the body element. */
}
#mainContent {
	padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
/* Heading */
 
h1, h2, h3, h4, h5, h6 {
	font-weight:normal;
}
h1 {
	font-size: 180%;
	font-weight: bold;
}
h2 {
	font-size: 150%;
	font-weight: bold;
}
h3 {
	font-size: 125%;
	font-weight: bold;
}
h4 {
	font-size: 100%;
}
/*set two wrapping divs for menu so it can be centered using left and right rules in successive divs (per EE replies)*/
#navbarwrap {
	position: relative;
	/*	margin: 0 auto;*/
	margin: 0 auto;
	width: 100%;
	height: auto;
	/*	height: 40px;*/
	background-color:#0066FF;
	overflow: hidden;
}
#navbar {
	position: relative;
	float: left;
	left: 50%;
	margin: 0;
	padding: 0;/*	margin: 0 auto;*/
/*	overflow: hidden;*/
/*	width: 100%*/
}
#navbarinner {
	position: relative;
	right: 50%;
}
#header {
	margin: 0;
	padding: 0;
	background-color: #99CC33;
}
#leftcolumn {
	width: 150px;
	float: left;
	height: 300px;/*	background-image: Template/Images/Backgrounds/bg_leftcolumn.gif;
	background-repeat: repeat-y;
	background-position: left top;*/
}
/*#rightcolumn {
}*/
</style>
</head>
<body>
<div id="container">
  <div id="navbarwrap">
    <div id="navbar">
      <div id="navbarinner">
        <ul id="MenuBar1" class="MenuBarHorizontal">
          <li><a class="MenuBarItemSubmenu" href="#">Item 1</a>
            <ul>
              <li><a href="#">Item 1.1</a></li>
              <li><a href="#">Item 1.2</a></li>
            </ul>
          </li>
          <li><a href="#">Item 2</a></li>
          <li><a href="#">Item 3</a></li>
          <li><a href="#">Item 4</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div id="header">
    <p>header</p>
  </div>
  <div id="leftcolumn">
    <p>left column</p>
  </div>
  <div id="mainContent">
    <h1>h1 Level Heading </h1>
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at ... </p>
    <h2>h2 level heading </h2>
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at ... </p>
    <!-- end #mainContent -->
  </div>
  <!-- end #container -->
</div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>

Open in new window

Overflow-Hidden-OFF-or-ON-IE7.png
Overflow-Hidden-ON-FF3.png
Overflow-Hidden-OFF-FF3.png
0
qeng
Asked:
qeng
  • 2
1 Solution
 
David S.Commented:
That's one of the problems with using overflow:hidden to contain floated elements. In this case you can give #navbarwrap float:left and #header clear:both

IE5-7 wrongly make elements contain their floated children in many situations. I suggest you read up on clearing and containing floats: http://www.dynamicsitesolutions.com/css/layout-techniques/#clearing_floats
0
 
qengAuthor Commented:
Kravimir,
Thanks.  Works like a charm.  You're a gift.
Will read up on the reference link you gave me.
I was setting this test file up in fact to try to troubleshoot another problem I was having with trying to make a vertical menu list's elements display their focussed state when the page which pertains to that link is loaded.  This is off-topic for this particular post so I will repost in a few minutes on the off-chance you might have few minutes to look at it and possibly guide me towards a solution.  This latter problem is a bit tricky because there are several cascaded sheets and dependency/specificity issues.  I've got it doing 'almost' what I want but can't get the links to display their focus state.  I'll try to explain properly in the next post.
0
 
qengAuthor Commented:
Thanks again Kravimir.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now