The layout is being disrupted by a bug in the nested list div in IE 7

I am currently in the process of creating a website with nested lists in the sidebar. The parent list contains children li elements. Initially, only 4 list items are displayed, and the rest should be hidden with an option to "Show All" above them.

Here is the HTML code:

<div id="sideMenuBox">
<div class="header">
    <h2 class="cufon">CATEGORIES</h2>
    <a class="moreLink" href="#" title="">All</a>
</div>
<div class="body"> <!-- menubox body -->
    <ul id="sideMenu">
        <li>
            <span><img src="images/icon-1.png" alt="icon" width="32" height="19" /></span>
            <a href="#" title="">Shopping Centers</a>
            <ul>
                <li><a href="#" title="">Online Shopping Sites</a></li>
                <li><a href="#" title="">Jewelers</a></li>
                <li><a href="#" title="">Gift Shops</a></li>
                <li><a href="#" title="">Florists</a></li>
                <div class="sbSubMenu" style="border:black 1px solid">
                    <li><a href="#" title="">Jewelers</a></li>
                    <li><a href="#" title="">Jewelers</a></li>
                    <li><a href="#" title="">Jewelers</a></li>
                    <li><a href="#" title="">Jewelers</a></li>
                </div>  <!--// sidebar submenu -->
                <li><a class="showAll" href="javascript:" title="" onclick="javascript:showMenu(this);">show all</a></li>
            </ul>
            <br class="clearFix" />
        </li>
    </ul>
</div> <!-- // menubox body -->
<div class="bottom"></div>
</div> <!-- // sideMenuBox -->

And here are the CSS codes:

#sideMenu { 
width:200px; height:auto;
margin:10px auto;
}
#sideMenu li{ 
list-style-type:none; 
min-height:25px;
line-height:18px;
height:auto;
border:blue 1px solid;
}
#sideMenu hr { width:100%; height:1px; color:#e69000; background:#e69000; margin:10px auto 5px; border:0;}
#sideMenu li span { width:40px; float:left;}
#sideMenu li a{ 
color:#003a69;
text-decoration:none;
font-size:16px;
font-weight:bold;
margin:0; padding:0;
}
#sideMenu li li { 
margin-left:50px; 
display:inline-block; 
line-height:20px; 
border:red 1px solid;
}
#sideMenu li li a { font-size:13px; height:1px;}
#sideMenu li li a.showAll,
#sideMenu li li a.showLess{ 
color:006aa6; 
text-decoration:underline; 
font-size:12px; 
font-weight:normal;
margin:10px 0;
padding-right:15px;
background:url(../images/arrow-down-blue.png) right center no-repeat;
}
#sideMenu li li a.showLess{ background:url(../images/arrow-up-blue.png) right center no-repeat;}
#sideMenu .sbSubMenu { 
width:100%; height:auto;
}

The code works perfectly in Firefox, Chrome, and IE8, but in IE7, there is an issue where the div is included within li elements and lis are placed outside the div, causing layout issues. I tried removing the div tags, which fixed the problem, but I need to hide list items after the first four as per project requirements, hence why they are enclosed in a div that is initially hidden.

To address this problem and seek expert advice, I have created an online demo page. You can view the live demo here:

Note: Borders have been added to visualize how list items and divs render in IE. While it functions well in other browsers, there are rendering issues in IE7. Despite trying various solutions, the problem persists.

Please provide your insights and recommendations.

Thank you in advance.

Answer №1

I appreciate your concern and assistance. After trying various methods, I was able to identify the issue causing trouble - it was the nested unordered list and list items structure. Specifically, placing a "DIV" tag within the inner structure of an "LI" caused layout disruptions in IE 7. Although removing the "DIV" tag resolved the problem, project requirements necessitated its presence for hiding the "LI"s.

After hours of frustration, I decided to replace the "DIV" with "LI," which successfully resolved the issue in both IE7 and other browsers.

The final revised code is as follows:

<ul id="sideMenu">
  <li>
       <span><img src="images/icon-1.png" alt="icon" width="32" height="19" /></span>
       <a href="#" title="">Shopping Centers</a>
       <ul>
           <li><a href="#" title="">Online Shopping Sites</a></li>
           <li><a href="#" title="">Jewelers</a></li>
           <li><a href="#" title="">Gift Shops</a></li>
           <li><a href="#" title="">Florists</a></li>
           <li class="sbSubMenu"> <!-- hidden list items -->
              <ul>
                  <li class="innerList"><a href="#" title="">Jewelers</a></li>
                  <li class="innerList"><a href="#" title="">Jewelers</a></li>
                  <li class="innerList"><a href="#" title="">Jewelers</a></li>
                  <li class="innerList"><a href="#" title="">Jewelers</a></li>
              </ul>
           </li>  <!-- // sidebar submenu -->
           <li class="Link"><a class="showAll" href="javascript:" title="" onclick="javascript:showMenu(this);">show all</a></li>
       </ul>
     </li> <!-- // main List Item --->
   </ul>

You can view the functioning page live in IE7 here: Link:

Thank you once again!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The speed at which Laravel loads local CSS and JS resources is notably sluggish

Experiencing slow loading times for local resources in my Laravel project has been a major issue. The files are unusually small and the cdn is much faster in comparison. Is there a way to resolve this problem? https://i.stack.imgur.com/y5gWF.jpg ...

Styling Easy-Autocomplete with jQuery

I am currently working on integrating autocomplete functionality using the jquery easy-autocomplete plugin npm install --save easy-autocomplete I am facing two issues related to its styling. The results are being displayed in a bulleted list format. I ...

Tips on creating adaptable images for mobile viewing

My coding conundrum involves the use of two columns - one for an image and the other for a description of that image. However, when viewing my site on mobile devices, the image is cut off at only half its height. Adjusting both columns to col-sm-6 results ...

Issues with centering background-position while using clip-path functionality

Struggling to center a background image? I initially suspected conflicting CSS rules, so I created a simplified demo to troubleshoot. After reviewing examples on SO and beyond, it seems like my approach is correct. Can anyone help identify what I might be ...

How come Angular8's routerLinkActive is applying the active class to both the Home link and other links in the navigation bar simultaneously?

Currently, I am facing an issue with routing in my project where the home tab remains active even when I click on other tabs. I have tried adding routerLinkActiveOption as a solution, but it doesn't seem to be working for me. <ul class="nav nav-ta ...

Make the select box stay in place as it is created from an array

I have been utilizing an array to generate a select box and it's functioning as expected. However, I am looking to make this select box "sticky," meaning I want the HTML form to retain the previously filled out values. Although I inserted the code in ...

Position Ionicons center above h3 header in Bootstrap

My icons keep aligning to the left: <section class="section-what-i-do"> <div class="container"> <h2>What I do</h2> <p class="sub-header" id="learn-more-section">Studying, creating, learning</p> < ...

What is the best way to customize the default button style for buttons in Angular Datables?

After integrating buttons into my Angular Datatables, I noticed that they have default styling, which makes them stand out from the rest of my web page (refer to the Column Visibility button in the screenshot below): https://i.sstatic.net/w7Y8g.png I att ...

Is there a way to bypass the initial result when using document.querySelectorAll?

this is my own unique html content <div class="content-body"> <table style="text-align:center;" class="table table-bordered"> <tbody> <tr> <th>Text Line</th> </tr> <tr> <td> ...

Is there a way to automatically scroll to the bottom of a div when it first

Looking to enhance my application with a chat feature that automatically scrolls to the bottom of the chat page to display the latest messages. Utilizing VueJs: <template> <div id="app"> <div class="comments" ...

The click function for the responsive navbar hamburger is not functioning properly

Having some trouble with the code not working in responsive mode. I've tested it on a 600px screen and the hamburger button doesn't seem to work (I click it and nothing happens). I've gone through both the CSS and JS multiple times but can&a ...

The Bootstrap modal is not properly clearing all attribute properties when it is hidden

Alrighty, so I've got this modal set up: <div id="modal-container" class="modal fade" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content center-block" style="displ ...

The table will remain empty for eternity as the page is being loaded using ngRoute

Currently, I am utilising Angular routers. app.config(function($routeProvider) { $routeProvider .when('/comment/list', { templateUrl: 'commentList.htm', controller: 'mainController' }) }); ...

Adjust the overall cost according to the quantity using jQuery or JavaScript

I'm currently working on a project that involves input fields for Product Price, Quantity Form Field, and displaying the Total price. My goal is to have the Total price automatically update based on the product price and quantity with jQuery. I am loo ...

Resizing a damaged HTML table to fit within a designated width using CSS

Here is a challenge - I have some broken HTML that I can't touch, and don't want to use JavaScript to fix. My goal is to make it fit within a specific width: http://jsfiddle.net/P7A9m/2/ <div id="main"> <table> <tr> ...

Using clearfix on every div element is essential to avoid container collapsing

Would it be beneficial to include clearfix in every div element to avoid container collapse issues? Or is it more practical to apply it only to specific classes, like so? <div class="container"> Additional div elements... </div> .containe ...

Angular select element is not functioning properly with the `addEventListener` method

My current project involves creating a table using the primeng library. The table consists of three rows and three columns, and all the data is static. Even though I am utilizing an external library, I find myself traversing the DOM directly. <p-table ...

Objective-C and the World of WebSockets

Possible Duplicates: Comparison of WebSockets, TCP/IP, and JavaScript/AJAX for iPhone chat Integrating WebSockets into a Cocoa application Hello all, our team is embarking on creating a bespoke iPhone chat app and deliberating the use of WebSocket ...

Methods for concealing the title and date when printing web content using JavaScript

When utilizing the window.print method to print out a specific screen, I encountered an issue. I need to hide the date in the top left corner of the image as well as the title (not the big heading) which has been intentionally blurred. I've come acro ...

Initiate the video tag playback by using jquery.play() function

Is there a way to make the video start playing as soon as the overlaying absolute div has faded out? I've tried using javascript and autoplay, but it doesn't seem to work without controls enabled. Any suggestions? Check out the HTML code below: ...