简体   繁体   English

Windows 8.1上IE11的HTML文本字段大小

[英]HTML text field size with IE11 on Windows 8.1

I am porting a web application that currently runs in IE6 and IE8, to run in IE11 on Windows 8.1. 我正在移植当前在IE6和IE8中运行的Web应用程序,以在Windows 8.1上的IE11中运行。

The most serious compatibility issue is regarding the size (ie. length) of text fields. 最严重的兼容性问题是关于文本字段的大小(即长度)。 These are typically appearing several mm longer than they do in the older browsers, which throws many page formats out - eg. 与旧版浏览器相比,它们的显示时间通常长几毫米,从而淘汰了许多页面格式-例如。 a three-part date field will overflow onto the next line. 由三部分组成的日期字段将溢出到下一行。

It appears to me that the problem lies with the use of SIZE=n to specify field length in characters. 在我看来,问题在于使用SIZE = n来指定字符的字段长度。 It seems that this is inconsistent between IE8 and IE9 onwards, and it would have been preferable to use STYLE="WIDTH:npx" . 看来这在IE8和IE9之后是不一致的,并且最好使用STYLE =“ WIDTH:npx” Link: http://msdn.microsoft.com/en-us/library/ie/ff986079(v=vs.85) 链接: http//msdn.microsoft.com/en-us/library/ie/ff986079(v = vs.85)

I am trying to find a solution that avoids having to apply this change to potentially hundreds of fields. 我试图找到一种避免将更改应用于潜在的数百个字段的解决方案。

I have so far investigated two possible solutions: (1) Remove the "x" (clear button) that IE11 puts in text fields, in case this was causing the size increase. 到目前为止,我已经研究了两种可能的解决方案:(1)删除IE11在文本字段中放入的“ x”(清除按钮),以防造成大小增加。 Unfortunately, the recommended solution for this (setting ms-clear) will not work as the browser must run in Compatibility Mode. 不幸的是,由于浏览器必须在兼容模式下运行,因此建议的解决方案(设置ms-clear)将无法使用。 (2) Increase the window size. (2)增加窗口大小。 This helps with some of the fields, but not many, and gives rise to other undesirable screen format issues. 这对某些字段有帮助,但对许多字段却没有帮助,并引起了其他不良的屏幕格式问题。

An example of a set of affected fields in HTML, together with the related CSS class definition, is as follows: HTML中一组受影响的字段以及相关的CSS类定义的示例如下:

HTML: HTML:

<TABLE WIDTH="625" BORDER="0">
<!-- Column 1 --><COL WIDTH="100">
<!-- Column 2 --><COL WIDTH="115">
<!-- Column 3 --><COL WIDTH="102">
<!-- Column 4 --><COL WIDTH="93">
<!-- Column 5 --><COL WIDTH="40">
<!-- Column 6 --><COL WIDTH="20">
<!-- Column 7 --><COL WIDTH="137">
<TR>
    <TD>Date of Birth:</TD>
    <TD><INPUT TYPE="hidden" ID="DateOfBirth" NAME="DateOfBirth" SIZE="10" CLASS="clsText" ONBLUR="validateField()" ONFOCUS="resetFldFocusFlag()">
                <INPUT ID="DateOfBirthDay" NAME="DateOfBirthDay" SIZE="2" CLASS="clsText" ONKEYUP="autoDateTab(this);" MAXLENGTH="2" ONBLUR="validateField()" ONFOCUS="resetFldFocusFlag()"> /
                <INPUT ID="DateOfBirthMonth" NAME="DateOfBirthMonth" SIZE="3" CLASS="clsText" ONKEYUP="autoDateTab(this);" MAXLENGTH="3" ONBLUR="validateField()" ONFOCUS="resetFldFocusFlag()"> /
                <INPUT ID="DateOfBirthYear" NAME="DateOfBirthYear" SIZE="4" CLASS="clsText" ONBLUR="validateField();" MAXLENGTH="4" ONFOCUS="resetFldFocusFlag()"></TD>
    <TD>Age Estimated?
    <INPUT TYPE="checkbox" NAME="AgeEstimated" ID="AgeEstimated" ONCLICK="AgeEstimatedEffects()" SIZE="1" VALUE="Y" ONBLUR="validateField()" ONFOCUS="resetFldFocusFlag()"></TD>
    <TD>App. Age or From:</TD>
    <TD><INPUT ID="ApparentAge" NAME="ApparentAge" MAXLENGTH="3" SIZE="3" CLASS="clsText" ONBLUR="validateField(); MoveFocusToAgeTo()" ONFOCUS="resetFldFocusFlag()"></TD>
    <TD>To:</TD>
    <TD><INPUT CLASS="clsText" ID="AgeTo" NAME="AgeTo" SIZE="3" MAXLENGTH="3" ONBLUR="validateField()" ONFOCUS="resetFldFocusFlag()"></TD>
</TR>
</TABLE>

CSS: CSS:

.clsText
{
    COLOR: black;
    BACKGROUND-COLOR: white;
    FONT-SIZE: 11px;
    FONT-FAMILY: 'Microsoft Sans Serif';
    TEXT-ALIGN: left;
    TEXT-DECORATION: none
}

All of the above fields defined with CLASS="clsText" are affected by this issue. 上面用CLASS =“ clsText”定义的所有字段都受到此问题的影响。

Any thoughts would be appreciated. 任何想法将不胜感激。

  1. Specify the width of the columns in percentage 以百分比指定列的宽度

  2. change the text boxes size definition by defining its size in percentage instead of fixed length. 通过以百分比(而不是固定长度)定义其大小来更改文本框的大小定义。 This can be achived by using style attribute inside input tag eg. 这可以通过在输入标签中使用style属性来实现。 style = "width:20%" instead of specifying it in pixels like the size = "4" style =“ width:20%”而不是像size =“ 4”这样以像素为单位进行指定

I know this will take some time to implement but will be a long term solution and will help in case of window resizing as well. 我知道这将需要一些时间来实现,但是将是一个长期的解决方案,并且在调整窗口大小的情况下也会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM