CSS min-width in IE6, 7, and 8

前端 未结 8 2218
执笔经年
执笔经年 2020-12-09 11:09

I found many answers to this question on Google, but none of them seem to work for all browsers.

I am looking for a CSS-only way to get min-width working on Firefox,

相关标签:
8条回答
  • 2020-12-09 11:17

    I use:

    min-width: 200px;
    _width: 200px; /* IE6 */
    
    0 讨论(0)
  • 2020-12-09 11:19
    min-height:expression( document.body.clientHeight +'px');
    min-width:expression( document.body.clientWidth +'px');
    
    0 讨论(0)
  • 2020-12-09 11:25

    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>
    
    0 讨论(0)
  • 2020-12-09 11:25

    After so many hack that i have tried none of them works for me for this "min-width" issue, but finally i got its solution for IE 8.

    Try to use this: <!DOCTYPE html> as your DOC type, this is HTML 5 DOC Type that turns your IE8 page to behave like mozilla or webkit browser.

    So apart for min-width and min-height issue, it solves many IE8 problems very easily.

    If my post helps you please mail me with your name thats it works for you.

    0 讨论(0)
  • 2020-12-09 11:26

    By default the Document mode in IE will be Quirks mode

    Solution: add the doctype on top of your html page

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    0 讨论(0)
  • 2020-12-09 11:27
    <style type="text/css">
    .table1 th a {
        display:inline-block;
        width:200px";
    }
    </style>
    
    <table>
        <tr>
            <th><a>title1</a></th>
            <th><a>title2</a></th>
        </tr>
        <tr>
            <td>text</td>
            <td>text</td>
        </tr>
    </table>
    
    0 讨论(0)
提交回复
热议问题