Cross-Browser Problem with Overflow Hidden Preventing Menu Expansion

Posted on 2009-04-16
Last Modified: 2012-05-06
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?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<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" />


/*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 {



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;*/


	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 {





<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>


              <li><a href="#">Item 1.1</a></li>

              <li><a href="#">Item 1.2</a></li>



          <li><a href="#">Item 2</a></li>

          <li><a href="#">Item 3</a></li>

          <li><a href="#">Item 4</a></li>





  <div id="header">



  <div id="leftcolumn">

    <p>left column</p>


  <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 -->


  <!-- end #container -->


<script type="text/javascript">


var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});





Open in new window

Question by:qeng
    LVL 42

    Accepted Solution

    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:

    Author Comment

    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.

    Author Closing Comment

    Thanks again Kravimir.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Photoshop CC 2015

    Photoshop has become the standard in image manipulation among professional photographers and graphic designers. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now