gpt4 book ai didi

html - 文本区域根据焦点调整大小并离开

转载 作者:太空宇宙 更新时间:2023-11-04 08:13:12 24 4
gpt4 key购买 nike

我遇到了一个以前从未见过的问题:一个普通的老式常规 html textarea,它会根据焦点调整大小。

即使我设置了所需区域的高度,它仍然会调整为更小或更大的大小,但没有明显的相关性。我试图删除我在该元素上的所有类(class),但没有成功。


这是 Bootstrap 吗?
我该如何解决?

问题短视频链接:
https://www.dropbox.com/s/7329y5a96ixajl4/18-34-46.wmv?dl=0

<textarea style="min-height: 150px; height: 150px; 
max-width: 100%;" type="text" name="jobDesc"
ng-model="req.jobDesc" placeholder="Write a description for the assignment">
</textarea>

最佳答案

Try using rows Attribute:

<textarea rows="4" >
This should force the text area to only show 4 lines, or 5, as you desire.
</textarea>

Anyway, I think you can check the size of your text area or the calculated properties, clicking on "inspect" on your browser (for example chrome). Then click on Styles/Computed and you will see the styles you are applying.

属性图片:

enter image description here

编辑:

I´ve tried to make a fiddle to think about which property is breaking it, try it. It it seems you need to look for a textarea:focus or similar inside your css`s :)

Changed snippet to show how also padding property can affect the size

#editor1 {height: 10px;}
#editor1:focus {height: 20px;}

#editor2:focus { padding-bottom: 10px;}
<textarea id="editor1" placeholder="Check it!!"></textarea>
<textarea id="editor2" placeholder="Check it!!"></textarea>

解决后通过 OP 的评论进行了改进:

我确实设法找出导致问题的原因。隐藏在其中一个 js 文件中的是一些用于管理调整文本区域大小的遗留代码。由于某些页面在实际页面顶部加载模板(在旁白/模态中),因此代码无法正确运行。感谢您抽出宝贵时间。它把我带到了我的

关于html - 文本区域根据焦点调整大小并离开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46101395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com