2013-05-07 116 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瀏覽器測試器和看起來很好實現這一目標。希望這可以幫助!

相關問題