Min-width in MSIE 6
foo { min-width: 100px } // for everyone
* html foo { width: 100px } // just for IE
(or serve a separate stylesheet to IE using conditional comments)
min-width and max-width with jQuery
to emulate max-width:
var maxWidth = 300;
if ( $('SELECTOR').width() > maxWidth ) $('SELECTOR').width(maxWidth);
the same can be applied for width, height, min and max with minor adjustments.
CSS min-width in IE6, 7, and 8
So it turns out that the necessary hack for getting min-width to work in all browsers isn't as ugly as many make it out to be.
All I had to do was add CSS for a div within the largeCell
and add an empty div at the end of the cell. The div is only 1px tall, so it doesn't really make the cell look larger than it should be.
<style type="text/css">
table.dataTable td {
white-space: nowrap;
}
table.dataTable td.largeCell {
white-space: normal;
min-width: 300px;
}
table.dataTable td.largeCell div {
margin: 0px 0px 0px 0px;
height: 1px;
width: 300px;
}
</style>
<table class="dataTable">
<tr>
<td>ID</td>
<td>Date</td>
<td>Title</td>
<td class="largeCell">A large amount of data like a description that could
span several lines within this cell.
<div></div>
</td>
<td>Link</td>
</tr>
</table>
How do I specify in HTML or CSS the absolute minimum width of a table cell
This CSS should suffice:
td { min-width: 100px; }
However, it's not always obeyed correctly (the min-width attribute) by all browsers (for example, IE6 dislikes it a great deal).
Edit: As for an IE6 (and before) solution, there isn't one that works reliably under all circumstances, as far as I know. Using the nowrap HTML attribute doesn't really achieve the desired result, as that just prevents line-breaks in the cell, rather than specifying a minimum width.
However, if nowrap is used in conjunction with a regular cell width property (such as using width: 100px), the 100px will act like a minimum width and the cell will still expand with the text (due to the nowrap). This is a less-than-ideal solution, which cannot be fully applied using CSS and, as such, would be tedious to implement if you have many tables you wish to apply this to. (Of course, this entire alternative solution falls down if you want to have dynamic line-breaks in your cells, anyway).
Issue with box-sizing border-box and min-width in IE 9
Hi came across your post when Googling for a similar issue with IE 8, although IE 8 supports box-sizing and min-height/width, from my tests, it seems IE 8 ignores border-box when using min-height/width on the same element
E.g.
#box {
min-height: 20px;
padding:4px;
box-sizing:border-box;
}
IE 8 height = 28px, Chrome 20 height = 20px;
Solution using css browser selectors http://rafael.adm.br/css_browser_selector/
#box {
min-height: 20px;
padding:4px;
box-sizing:border-box;
}
.ie8 #box, .ie9 #box {
min-height: 12px;
padding:4px;
}
How to make IE support min-width / max-width CSS properties?
If what you are saying is true, IE9 would be deviating form the spec. However, I cannot duplicate your complaint. Using your example, IE9 respects min-width
if width
is less than 150px
per this jsfiddle.
EDIT:
NOTE: Quirks Mode follow different rules and does not comply with standard CSS in any browser. If you add a doctype to the page, this should resolve the problem (add: <!DOCTYPE html>
).
To expand on the issue, Quirks Mode is not standardized. There are some things that most browser implement, but new features are undefined in those defacto standards. Thus, some browsers are allowing new CSS to be used (as you have observed), but IE9 is ignoring new css values, as they have no place in Quirks Mode.
max-width not working for IE 11
I think your problem is not coming from max-width
but from main
element...
The main
element is not fully supported by IE11 (source).
2 solutions :
- Change your
<main>
element to a<div>
. Demo : http://jsfiddle.net/z4s01yxz/2/ - Add
main { display: block; }
to your CSS. Demo : http://jsfiddle.net/z4s01yxz/1/
Related Topics
iOS CSS Opacity + Visibility Transition
Add Prefixes to CSS Class Names Using Less or SASS
Change Navbar Height in Bootstrap3
Tailwind CSS Classes Not Showing in Storybook Build
MAC Safari 5.0.4 Bug When Using Google Maps API
How to Remove Blogger CSS Widget Bundle
Gradient Effect for Triangle Shape Borders
Why Are My Descenders Being Cut Off When Using CSS @Font-Face
Why Are Inline-Block Elements Not Displayed Correctly in Internet Explorer 8
How to Filter and Show Only Applied CSS in Chrome Developer Tools (Like Firebug in Firefox)
Firefox CSS Animation Smoothing (Sub-Pixel Smoothing)
Why Do Flexbox Item Images Resize Differently According to Their Initial Size
How to Turn Off SASS Rgb -> Color Name
How to Get My @Import Stylesheet to Override the Main Stylesheet
Css3 Appearance Property for Ie
Css: Fixed with Horizontal Menu, with Variable Width Tabs, Using Ul