输入宽度与textarea宽度 [英] input width vs textarea width

查看:83
本文介绍了输入宽度与textarea宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

读完线程
输入大小与宽度



我很清楚,我们不应该使用size属性而是css风格。



什么是跨浏览器css,同样的宽度为输入[文本]和textarea?



BTB,我试过

  #idInputText,#idTextArea {
字体:继承;
width:60ex;

}



它正确吗?更好的解决方案?



感谢您提供任何帮助。

解决方案

原生填充对于文本输入元素不同。您需要为输入元素和textarea元素以及实验分配不同的宽度。

  #form input.textfield {width:10em ; } 
#form textarea {width:9em; }

只需抛出一些默认样式(我更喜欢ems)并弹出打开Firebug并通过更改大小 $ b

我通常在< input type = text>>上放置一个 class = textfield ; 所以我不是针对< input type = submit> 或类似的。

After reading the thread Input size vs width

I'm clear that we should not use size attribute but css style.

What will be the cross browser css that shows exactly same width for both input[text] and textarea?

BTB, I tried

#idInputText, #idTextArea {
font: inherit;
width: 60ex;

}

Is it correct? any better solution?

Thanks in advance for any help.

解决方案

The native padding for text input elements differ. You will need to assign a different width to input elements and textarea elements and experiment.

#form input.textfield { width:10em; }
#form textarea { width:9em; }

Just throw some default styles ( I prefer ems ) and pop open Firebug and experiment by changing the size values.

I usually throw a class=textfield on <input type=text> so I don't target <input type=submit> or similar.

这篇关于输入宽度与textarea宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆