textarea与100%宽度忽略父元素的宽度在IE7 [英] textarea with 100% width ignores parent element's width in IE7

查看:107
本文介绍了textarea与100%宽度忽略父元素的宽度在IE7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格中有以下textarea:

 < table width =300>< tr& < td> 

< textarea style =width:100%>
longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring
< / textarea>

< / td>< / tr>< / table>在textarea中有一个长字符串,textarea伸展出来容纳它在IE7中的一行,



有关如何在IE中修复此问题的任何想法?

解决方案

将宽度应用于 td ,而不是



编辑:@Emmett - 宽度可以很容易地通过CSS应用。

  td {
width:300px;
}

产生所需的结果。或者,如果您使用jQuery,可以通过脚本添加宽度:

  $('textarea [width = 100% ]')。parent('td')。css('width','300px'); 

很明显,如果开发约束阻止您可以直接应用它。


I have the following textarea in a table:

<table width="300"><tr><td>

<textarea style="width:100%">
longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring
</textarea>

</td></tr></table>

With a long string in the textarea, the textarea stretches out to accommodate it in one line in IE7, but retains its 300px width in other browsers.

Any ideas as to how to fix this in IE?

解决方案

Apply the width to the td, not the table.

EDIT: @Emmett - the width could just as easily be applied via CSS.

td {
    width: 300px;
}

produces the desired result. Or, if you're using jQuery, you could add the width through script:

$('textarea[width=100%]').parent('td').css('width', '300px');

Point being, there's more than one way to apply a width to a table cell, if development constraints prevent you from applying it directly.

这篇关于textarea与100%宽度忽略父元素的宽度在IE7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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