宽度设置为100%时文本框太宽 [英] text box too wide when width set to 100%

查看:99
本文介绍了宽度设置为100%时文本框太宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在IE6或FireFox中显示以下内容,则文本框强制

秒DIV扩展超过其15em宽度。有没有办法让文字

框适合DIV(最好不要失去默认边框)?


提前谢谢


码头


<!DOCTYPE html PUBLIC'' - // W3C // DTD XHTML 1.0严格// EN''

''http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd''>

< HTML xmlns =''http:// www。 w3.org/1999/xhtml''xml:lang =''en''lang =''en''>

< HEAD>

< / HEAD>

< BODY>

< DIV style =" width:15em; background-color:green;">

& nbsp;

< / DIV>

< DIV style =" width:15em; background-color:red;">

< input type =''text''style =''width:100%;''>

< / DIV>

< ; / BODY>

< / HTML>

解决方案

您尝试过:

display:block; width:auto;?


chris


Piers Lawson写道:

如果在IE6或FireFox中显示以下内容,则文本框强制
第二个DIV扩展超过其15em宽度。有没有办法让文本
框适合DIV(最好不要失去默认边框)?

提前谢谢

Piers
<!DOCTYPE html PUBLIC'' - // W3C // DTD XHTML 1.0 Strict // EN''
''http://www.w3.org/TR/xhtml1/DTD/ xhtml1-strict.dtd''>
< HTML xmlns =''http://www.w3.org/1999/xhtml''xml:lang =''en''lang =''en' '>
< HEAD>
< / HEAD>
< BODY>
< DIV style =" width:15em; background-color:green;" ;>
& nbsp;
< / DIV>
< DIV style =" width:15em; background-color:red;">
< ; input type =''text''style =''width:100%;''>
< / DIV>
< / BODY>
< / HTML>



Piers Lawson写道:

如果在IE6或F中显示以下内容ireFox,文本框强制第二个DIV扩展超过其15em宽度。


100%+非零填充+非零边界> 100%

<!DOCTYPE html PUBLIC'' - // W3C // DTD XHTML 1.0 Strict // EN''
''http://www.w3.org/TR /xhtml1/DTD/xhtml1-strict.dtd''>
< HTML xmlns =''http://www.w3.org/1999/xhtml''xml:lang =''en''lang =''en''>




为什么使用XHTML? (除非您不是因为所有标签和属性

名称都是语言中的小写)。


-

David Dorward< http://blog.dorward.me.uk/> < http://dorward.me.uk/>

Home是〜/ .bashrc的地方


David Dorward< do*****@yahoo.com>写道:

Piers Lawson写道:

如果在IE6或FireFox中显示以下内容,则文本框强制
秒DIV扩展超过其15em宽度。



100%+非零填充+非零边界> 100%




的确如此。但既然他想要边境,他应该用什么价值来代替100%? AFAIK没有办法说


宽度:100% - 0.2em; border-width:0.1em


让它加起来吧。使用

边框宽度的百分比是不会与

不同宽度的其他输入框一起使用。


-
$ b $bJónFairbairn Jo ******* ****@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (2005-02-09更新)


If the following is displayed in IE6 or FireFox, the text box forces the
second DIV to expand beyond its 15em width. Is there a way to have the text
box fit within the DIV (preferably without losing its default borders)?

Thank you in advance

Piers

<!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.0 Strict//EN''
''http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd''>
<HTML xmlns=''http://www.w3.org/1999/xhtml'' xml:lang=''en'' lang=''en''>
<HEAD>
</HEAD>
<BODY>
<DIV style="width:15em;background-color: green;">
&nbsp;
</DIV>
<DIV style="width:15em;background-color: red;">
<input type=''text'' style=''width:100%;''>
</DIV>
</BODY>
</HTML>

解决方案

Have you tried:
display:block;width:auto;?

chris

Piers Lawson wrote:

If the following is displayed in IE6 or FireFox, the text box forces the
second DIV to expand beyond its 15em width. Is there a way to have the text
box fit within the DIV (preferably without losing its default borders)?

Thank you in advance

Piers

<!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.0 Strict//EN''
''http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd''>
<HTML xmlns=''http://www.w3.org/1999/xhtml'' xml:lang=''en'' lang=''en''>
<HEAD>
</HEAD>
<BODY>
<DIV style="width:15em;background-color: green;">
&nbsp;
</DIV>
<DIV style="width:15em;background-color: red;">
<input type=''text'' style=''width:100%;''>
</DIV>
</BODY>
</HTML>



Piers Lawson wrote:

If the following is displayed in IE6 or FireFox, the text box forces the
second DIV to expand beyond its 15em width.
100% + non-zero padding + non-zero border > 100%
<!DOCTYPE html PUBLIC ''-//W3C//DTD XHTML 1.0 Strict//EN''
''http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd''>
<HTML xmlns=''http://www.w3.org/1999/xhtml'' xml:lang=''en'' lang=''en''>



Why are you using XHTML? (Except you aren''t since all tag and attribute
names are lower case in the language).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


David Dorward <do*****@yahoo.com> writes:

Piers Lawson wrote:

If the following is displayed in IE6 or FireFox, the text box forces the
second DIV to expand beyond its 15em width.



100% + non-zero padding + non-zero border > 100%



Indeed. But since he wants the border, what value should he
put in place of 100%? AFAIK there''s no way to say

width: 100% - 0.2em; border-width: 0.1em

to get it to add up right. And using a percentage for the
border width isn''t going to chime with other input boxes of
different widths.

--
Jón Fairbairn Jo***********@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2005-02-09)


这篇关于宽度设置为100%时文本框太宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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