简体   繁体   English

隐藏的textarea填充在IE 11中不起作用

[英]Hidden textarea padding not working in IE 11

I am trying to add padding to a simple textarea . 我试图将填充添加到一个简单的textarea。

It works perfectly if the textarea is visible on load , but if you dynamically(jQuery) show the textarea then the padding does not take effect. 如果textarea在加载时可见,则完美地工作,但是如果动态地(jQuery)显示textarea,则填充不会生效。

The above problem only happens in IE and importantly only happens before you type anything in the textarea . 上面的问题仅发生在IE中, 重要的是仅发生在textarea中键入任何内容之前。 Once you type something the padding immediately takes effect. 键入内容后,填充立即生效。

Is it some IE bug or anything can be done to solve this problem ? 是某些IE错误还是可以解决此问题的任何方法?

I have made a simple demo here : http://loadmycode.com/build/lymj6_XFP/12 我在这里做了一个简单的演示: http : //loadmycode.com/build/lymj6_XFP/12

Thanks for the help. 谢谢您的帮助。

This looks like an IE bug. 这看起来像IE错误。 If the content is not empty, like $('textarea').val(' ').show().focus(); 如果内容不为空,例如$('textarea').val(' ').show().focus(); it displays the padding, but if you delete the space the cursor goes back to the top. 它显示填充,但是如果删除空格,光标将返回顶部。

Since it works when the textarea is displayed when the page is loaded, you can use this work around: remove display: none; 由于它在加载页面时显示文本区域时起作用,因此您可以使用以下解决方法:remove display: none; from the style and add $('textarea').hide(); 从样式中添加$('textarea').hide(); to a ready event on your page. 到页面上的ready事件

Demo: http://loadmycode.com/build/lymj6_XFP/29 演示: http//loadmycode.com/build/lymj6_XFP/29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM