Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to emulate min-width in IE8

The IE8 documentation says it supports min-width, but it doesn't seem to work for me.

The html I want to be a minimum width is in table cells.

I saw another question here which suggested adding a 1-pixel height div to each cell, with a width setting, but that doesn't work - IE renders it as 18 pixels high, for some reason.

Here is the html code:

<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<style type="text/css">
table.keyboard div.key {
    height: 50px;
    font-size:50px;
    border: 5px outset gray;
    min-width: 60px;
    text-align: center;
}
table.keyboard div.spc {
    height: 1px;
    width: 60px;
    background-color: green;
}

table.keyboard td:hover {
    background-color: lightblue;
}
table.keyboard {
    border: 3px inset blue;
}
</style>
</head>
<body>
<div id="body">
<div>Here is some stuff</div>
<table class='keyboard'>
    <tbody>
        <tr>
            <td><div class='key'>1</div><div class='spc'></div></td>
            <td><div class='key'>2</div><div class='spc'></div></td>
            <td><div class='key'>3</div><div class='spc'></div></td>
            <td><div class='key'>4</div><div class='spc'></div></td>
            <td><div class='key'>5</div><div class='spc'></div></td>
        </tr>
    </tbody>
</table>
</div>
</body>
</html>

The "spc" div appears 18 px high!

Of course, if min-width worked, I wouldn't need the div...

<table class='keyboard'>
    <tbody>
        <tr>
            <td><div class='key'>1</div></td>
            <td><div class='key'>2</div></td>
            <td><div class='key'>3</div></td>
            <td><div class='key'>4</div></td>
            <td><div class='key'>5</div></td>
        </tr>
    </tbody>
</table>

Any clues?

Just to make this easier, I have put 3 different versions of this code on my website.

like image 988
Nikki Locke Avatar asked Nov 11 '11 19:11

Nikki Locke


1 Answers

http://jsfiddle.net/3htmA/

IE8. your code works perfect.

like image 103
bravedick Avatar answered Sep 29 '22 21:09

bravedick