html - 如何正确指定文本区域宽度?使用 cols 属性我使用不同的浏览器获得不同的宽度

标签 html css xhtml textarea

我对 textarea 的宽度定义有一些问题

所以,我有这种情况:

<div id="dialogReject" title="">
    <table style="visibility: hidden;" id="rifiutaTable" border="0" class="standard-table-cls" style="width: 100%!important">

        <tbody style="background-color: #ffffff;">
            <tr>
                <td style="font: 16px Verdana,Geneva,Arial,Helvetica,sans-serif !important">Inserire note di rifiuto</td>
            </tr>

            <tr>
                <td>
                    <textarea style="visibility: hidden;" rows="5" cols="70" id="myRejectNote"></textarea>
                </td>
            </tr>

            <tr>
                <td>
                    <input class="bottone" readonly="readonly" type="text" value="Rifiuta" onclick="rifiuta()"/>
                </td>
            </tr>
        </tbody>
    </table>

</div>

具有 id="dialogReject" 的 div 表示一个 JQuery 对话框,其中有一个 textarea,这个:

<textarea style="visibility: hidden;" rows="5" cols="70" id="myRejectNote"></textarea>

因此,如您所见,此 textarea 的宽度由其列号指定:cols="70"

实际上列数设置为 70,这对 FireFox 很好,实际上这是获得的结果:

enter image description here

没问题,但是当我尝试在 Explorer 上打开它时,我得到:

enter image description here

如您所见,仅使用 70 列不会将所有水平空间填充到我的对话框中(我必须增加到 100 列,但这样在我使用 FireFox 时会退出对话框)

我该如何解决这个问题?我能否以某种不同的方式指定 textarea 宽度,以便为所有浏览器正确呈现它?

谢谢

最佳答案

textarea应用width:100%

 <textarea style="visibility: hidden; width:100%;" rows="5" cols="70" id="myRejectNote"></textarea>

DEMO

关于html - 如何正确指定文本区域宽度?使用 cols 属性我使用不同的浏览器获得不同的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30526020/

相关文章:

javascript - 防止在 HTML 中选择

php - 无论如何让 Notepad++ 同时突出显示 PHP 和 HTML?

html - 如何将文本与 <div> 中的图像垂直对齐

css - GMail、MailChimp 在表格中的图像之间添加间距

css - 放大到原始页面宽度的 180% 时网页页脚出现问题

css - ADF Skin.css - 自定义问题

html - 如何更改按钮悬停属性中的文本颜色

html - 如何为美化分配 css(语法荧光笔)

javascript - 如果我不在 <div> 中声明 ID 会怎样?

javascript - 加载时聚焦输入框