让 TextArea 在不同浏览器中看起来都一样?

问题描述 投票:0回答:3

这个问题我还没有找到满意的答案,所以我来了,

这就是我的 textareaChrome 上的样子:

enter image description here 这是同一页面在 FireFox 上的样子:

enter image description here

这是该文本区域的 HTML:

<textarea class="t-field" cols="58" id="message" name="message" rows="6"></textarea>

所以,我想知道的是... CSS 技巧让文本区域在浏览器中表现相同并看起来相同?

预先感谢您的回答, 亲切的问候!

html css cross-browser
3个回答
3
投票

不要使用

cols
rows
属性,而是尝试使用 CSS
width
height
属性


1
投票

正如已经指出的,您应该使用

width
height
来固定区域的大小。行和列将根据浏览器使用的字体大小而变化,并且可能会接受其他解释变化。


0
投票

不要使用

cols
rows
,只需使用 css
width
height
。例如这样

textarea {
            width: 100%;
            height: 150px;
            padding: 12px 20px;
            box-sizing: border-box;
            border: 2px solid #ccc;
            border-radius: 4px;
            background-color: #f8f8f8;
            font-size: 16px;
            resize: none;
          }

保存并在两个浏览器上运行。更重要的是,请使用

ctrl+F5
进行硬刷新或强制重新加载。如果您只按
F5
,它只会刷新,如果您使用
ctrl+F5
,则会显示结果。

© www.soinside.com 2019 - 2024. All rights reserved.