gpt4 book ai didi

html - 带有长文本的输入文本字段增加了 IE7 中的表格单元格

转载 作者:太空宇宙 更新时间:2023-11-03 18:45:49 25 4
gpt4 key购买 nike

我有一个表格,其中第二列应该有一定的宽度(例如 50px)。当我在该列中有一个宽度为 100% 的文本框,但有很多文本时,列的宽度总是与文本一样长。

看我的代码+截图

<!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 长?

最佳答案

您可以通过使用 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 测试仪上检查过了,看起来不错。希望这对您有所帮助!

关于html - 带有长文本的输入文本字段增加了 IE7 中的表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16420104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com