我已将以下简单的 HTML 代码上传到 http://losthobbit.net/temp/anchor.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Anchor Test</title>
</head>
<body>
<div style="width:100%;height:100%">
<input maxlength="250" type="text" name="Text2" id="Text2" style="position: absolute;
top: 13px; left: 265px; right: 15px; height: 20px; text-align: Left">
</div>
</body>
</html>
如您所见,我指定了左右,但没有指定宽度,以使其拉伸(stretch)。
在 Chrome 中,它会随着浏览器大小的调整而拉伸(stretch),但这在 IE8 或 FireFox 中不起作用。关于如何解决此问题的任何想法?
谢谢
请注意,人们建议我使用宽度百分比...不幸的是,它并没有解决我的问题。我想要与我在 Chrome 中完全相同的行为,即左右 anchor 。这意味着拉伸(stretch)不是固定的百分比。
最佳答案
给出 <input>
父元素,在其上设置当前样式并给出 <input>
元素 width:100%
.
<div style="width:100%;height:100%">
<span style="position: absolute; top: 13px; left: 265px; right: 15px; height: 20px; text-align: Left">
<input maxlength="250" type="text" name="Text2" id="Text2" style="width:100%; height:100%;">
</span>
</div>
Working demo: http://jsbin.com/ayiwa5
关于html - 在 HTML 中,如何让输入框在 IE8 中拉伸(stretch)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6225108/