I'm running into a really weird issue in IE (specifically tested in IE 11 & edge mode on Windows 7). IE seems to add extra padding/height to the list-items in the nested <ul>
. Screenshots and tests below. If someone could point me the right direction of how to fix this, that would be great, I've tried a few different things and don't know what's going wrong.
I have a nested <ul>
, like so:
HTML
<ul>
<li class='static'>Example Menu Item</li>
<li class='static'>
Another Example
<ul class='dynamic'>
<li class='dynamic'>Dropdown Menu Item</li>
</ul>
</li>
</ul>
CSS
ul.dynamic
{
z-index: 10000;
list-style-type: none;
padding: 0;
margin: 0;
background: #ccc;
min-width: 200px;
}
li.dynamic
{
display: block;
white-space: nowrap;
/* Fix for bug in IE10/11/Edge */
list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);
}
The list-style-image
setting, if you're wondering, is a fix for a previous bug I found in IE wherein regardless of the list-style
or list-style-type
setting, the submenu would still have the list "dots" next to it. That encoded data is the smallest possible transparent image.
Tests
I've tried a lot of different things, from setting both the <ul>
and the <li>
to fixed height, box-sizing: (content-box|border-box)
, white-space: nowrap
, and/or padding: 0; margin: 0;
, with no tangible results.
Strangely, if I set basically anything differently in the IE inspector, including changing existing values on the <li>
, when the repaint occurs, the <li>
's suddenly snap back to the right height. However, if I put any of those changes in my stylesheet and reload, the same problem occurs.
Furthermore, this problem isn't specific to my machine. I've had a few others (also, Windows 7, IE11) test it and run into the exact same problem. It's also specific to IE. The menu looks fine in every other (up-to-date) browser, but when I run it in 11 or 11's compat modes for IE10 and 9, I see the same issue.
I also cannot created a reduced test case in JSFiddle (or similar), as I cannot replicate this bug in JSFiddle, which is the strangest part. That would also imply that my CSS has more affecting it than I think, but the only things that I did not include in the CSS above are a few styles that only add color & a border-bottom
, and some inline styles that are set by javascript to set its top
, left
, and position
correctly as a dropdown menu.
Notes
My doctype is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
And I am not setting any meta tag that would force IE into an older compat mode.
Finally, these <ul>
menus aren't hardcoded, they are generated by the ASP.NET <asp:Menu>
element with RenderingMode="List"
and IncludeStyleBlock="false"
.
Screenshots
Chrome
Internet Explorer 11 (no-compat mode)
Above is a shot of the <li>
in question with the inspector highlighting it, showing no padding or margin making up this
Thanks for taking the time to read all this! If you have any pointers or suggestions, I would be happy to hear it!