Link to home
Start Free TrialLog in
Avatar of jamiemz14
jamiemz14Flag for United States of America

asked on

How to fix IE6 Duplicate Content CSS Bug without using display:inline

The code I have is doubling content in IE6.  The reason is found here http://www.positioniseverything.net/explorer/dup-characters.html, and is because I am using display:block; and  display:hidden.    The solutions I find say to change any reference to display:block to display:inline.  My code is for a left navigation, and when moused over the content highlights, I need it to display block so that the text is highlighted as a block.  There are 3 levels,   NonGroup which means it is just a navigation item with no sub level links,  Group which means that is a navigation item that has sub level link that it will need to show when clicked, and Option which is the sub level links under Group.     There also is a javascript file that changes the class of the div to show or hide the options.  

My question is:  Is there a way to fix this bug other than changing my code to Display:inline?
I've included the code below:

CSS Code
---------------      
                .show {
            display:inline;
      }
      .hide {
            display:none;
      }
                .NonGroup {
            display: block;
            height: 100%;
            width: 155px;
            line-height: 18px;
            padding-left: 7px;
            padding-bottom:10px;
            text-decoration: none;
            font-weight:bold;
      }
            .NonGroup:hover {
                  text-decoration: none;
                  background-image:url(images/Design/highlight.GIF);
            }
      .Group {
            display: block;
            height: 100%;
            width: 155px;
            line-height: 18px;
            padding-left: 7px;
            padding-bottom:10px;
            text-decoration: none;
            font-weight:bold;
      }
            .Group:hover {
                  text-decoration: none;
                  background-image:url(images/Design/highlight.GIF);
            }
      .Option {
            display: block;
            height: 100%;
            width: 155px;
            line-height: 18px;
            padding-left: 7px;
            padding-bottom:10px;
            text-decoration: none;
            z-index:9999;      
      }
            .Option:hover {
                  background-image:url(images/Design/highlight.GIF);
                  text-decoration: none;
                  z-index:9999;
            }
HTML Code
----------------
  <a href="PublicReports.html" class="NonGroup" id="Public Reports">Public Reports</a>

  <a href="KeepingYouHealthy/default.html" onClick="expandCollapse('Keeping You Healthy')" class="Group" id="Keeping You Healthy">Keeping You Healthy</a>
        <div class="hide" id="Keeping You HealthySubs">
             <a href="GeneralHealthResources.html" class="Option" id="General Health Resources">General Health Resources</a>
              <a href="Prevention.html" class="Option" id="Prevention">Prevention</a>  
              <a href="ManagingYourHealth.html" class="Option" id="Managing Your Health">Managing Your Health</a>    
        </div>

JavaScript
---------------
function expandCollapse (navLevel) {
/*event fires when a group with sublevels is clicked, it either collapses or expands the clicked group*/

      //hide any expanded nav
            hideNav();

      //Now show the new nav level
            var subnavLevel = navLevel + "Subs" //Subs is added so that it expands the sub level and not the item sent
            var selectedNavLevel = document.getElementById(subnavLevel);
            

            if (selectedNavLevel.className=="hide") {
                  selectedNavLevel.className="show";
                  //Set expandCookie
                  createCookie('pwhExpandCookie', navLevel ,0);
            }      
      }
function hideNav(){
      //check to see if there currently is an expanded nav item and collapse it
            var expandedCookieName= readCookie('pwhExpandCookie');
            var navExpanded = document.getElementById(expandedCookieName +"Subs");
            if (navExpanded) {      
                  navExpanded.className="hide";
                  eraseCookie('pwhExpandCookie');
            }
}
   
Avatar of ruidovisual
ruidovisual
Flag of Mexico image

I haven't read the whole code but you might try with: display:inline-block;
Avatar of jamiemz14

ASKER

I just tested your suggestion and changed all of the blocks to inline-block, but I'm still getting the same results.  Thanks for the idea, though!
Can you post a link? it would ease things for me : )
I can't provide a link due to security, but I can provide you with a file with the code functioning.  Change the txt file to an html file, and it will show you a general idea of how the navigation will work.  If you view it in IE6, you will see when mousing over the items up and down that the content duplicates and displays improperly.
IE6Bug.txt
SOLUTION
Avatar of ruidovisual
ruidovisual
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, i have not actually tested your code to see the issue, but have you tried applying hasLayout as the article suggests?
ruidovisual: That's odd that it's not duplicating in IE6 for you, I've had multiple people test this on different machines with the same results - maybe it's because the image background isn't there?  I attached that for you here, if you wanted to add it.  It sometimes takes a few mouseovers up and down to get it to appear.
highlight.GIF
brunobear: I'm not exactly understanding how to apply hasLayout - from what I read one way is to just need to make sure that each of the elements has a width assigned to it in the CSS?  I went thru and did added a width: to each one of the CSS styles for my divs and it didn't seem to make a difference.  If that's the wrong way to implement, let me know, I'd be glad to try it! - Thanks!
There are other ways to implement it without needing to apply a width, but applying the width should have the same effect of setting hasLayout. setting hasLayout using fixes a lot of IE problems, so just wanted to confirm it had been tested.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial