CSS: table and table-cell replacement for IE7
There are two ways to accomplish this. The first:
#header-nav{
overflow: hidden;
zoom: 1; /* IE6 and below work around */
}
#header-nav li{
float: left;
margin: 0;
padding: 0;
}
#header-nav li a{
display: block; /* if you want height and width */
}
The second:
#header-nav li{
margin: 0;
padding: 0;
display: inline;
}
Personally I use the first of the two as it provides a bit more control for styling a block for color, width, height, margin, padding, etc. Plus, when you do a:hover the entire box is a link; not just the text. My recommendation is to not use tables. The results are unpredictable as you have seen. Not to mention, now its easier to add sub-menu's, using JQuery or CSS.
IE7 and the CSS table-cell property
A good way of solving this setting the display
value to ''
:
<script type="text/javascript">
<!--
function toggle( elemntId ) {
if (document.getElementById( elemntId ).style.display != 'none') {
document.getElementById( elemntId ).style.display = 'none';
} else {
document.getElementById( elemntId ).style.display = '';
}
return true;
}
//-->
</script>
The empty value causes the style to revert back to it's default value. This solution works across all major browsers.
CSS display table in IE
IE7 doesn't support display:table
, your code looks fine in IE8, IE9 and IE10. So either you must use an actual <table>
or, if it's an option, use float
s instead.
No other way, I'm afraid.
Edit: Apparently this is for your page layout. You shouldn't be using <table>
or display:table
. Just float some DIVs man!
IE7 gets the content in my table to overlap
Three things:
The code would be much easier to fix and manipulate if you separated structure (HTML) from style (CSS). Not a terrible criticism, just an observation.
You could remove the
positioning
andfloats
in yourtd
s and give the elementsdisplay:inline-block
. Might work.If that fails, use a conditional comment to target IE7 (eg.,
<!--[if IE 7]>
) and apply widths to thetd
s there.
Display already hidden table cells in IE with CSS
You need to use display: table-cell;
or display: table-row;
in your separate class, for your <td>
and <tr>
tags respectively.
This won't work in IE6/7, so there are 2 other alternatives:
- Nest a
<span>
tag and use thedisplay: (none|block)
property in CSS on this instead. - Use
text-indent: (-9999em|0)
to push the text off screen.
Table layout wrong in IE(7)
I assume you are complaining about the minimal height of the middle row (the one containing only rowspanned cells), and the enlarged height of the adjacent rows to compensate, leaving gaps between the divs.
IE cannot calculate optimal row heights when the row contains only rowspanned cells. The usual solution when you absolutely cannot rejig it to get rid of the rowspan is to add a 1px 'dummy' column to one side of the table, containing empty cells, each with the 'height' set to how high the row should be.
But yes, depending on what you're planning to do with this, a CSS layout may well be more appropriate. If it's really a fixed-pixels-for-everything layout like this example, absolute positioning for each div will be a lot, lot easier.
Other bits: CSS width/height values require units (presumably 'px'); valign/cellspacing/etc. can be more easily done in a stylesheet even if you are using table layouts; a standards-mode DOCTYPE may prevent some of the worse IE bugs (although, not this old, non-CSS-related one).
Related Topics
Vertical and Horizontal Alignment of Text with CSS
Why Does The Img Tag Accept The Margin-Top Property
Use Full Width Excluding Overflow Scrollbar with "Position: Absolute"
Showing The Jsf Error Messages
Why Does Input's Size Increase in CSS Grid Layouts
To Change Text-Color in Mat-List-Option
When Do Nested Child Elements Expand Their Parent Elment
How to Align a Button to The Far Right in Mui Appbar
Plain <Select> Element Vs Bootstrap's Dropdown Element Rendered on Mobile Device
Select All Block Level Elements with CSS
Why Is Google Font Weight Not Working
Google Fonts External CSS Vs Copying The Code of External CSS in My CSS
CSS Media Queries Not Working in Safari
How to Add Multiple Browser Specific Values into a CSS Style in React