2013-05-07 78 views
1

我有一个表格,其中第二列应该有一定的宽度(例如50px)。 当我在此列中有一个宽度为100%的文本框,但有很多文本时,列的宽度始终与文本一样长。长文本输入文本字段在IE7中增加表格单元格

看到我的代码+截图

<!DOCTYPE HTML> 
<html> 
<head runat="server"> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Test</title> 
</head> 

<body> 


<table border="1"> 
    <tr> 
    <td></td> 
    <td style="width:50px;"><input type="text" value="very long text which doesn't fit into the whole textbox" style="width:100%" /> 
    </td> 
    </tr> 
</table> 

</body> 
</html> 

enter image description here

我如何可以强制列在IE7 50px的长?

回答

0

您可以通过使用IE条件注释如下

<!DOCTYPE HTML> 
<html> 
<head runat="server"> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Test</title>  
    <style> 
     .myInput{width: 100%;} 
    </style> 
    <!--[if IE 7]> 
     <style>   
      .myInput{width: 50px;} 
     </style> 
    <![endif]--> 
</head> 

<body> 
<table border="1"> 
    <tr> 
    <td></td> 
    <td style="width:50px;"><input class="myInput" type="text" value="very long text which doesn't fit into the whole textbox"/> 
    </td> 
    </tr> 
</table> 
</body> 
</html> 

我已经检查这个IE浏览器测试器和看起来很好实现这一目标。希望这可以帮助!

相关问题