中(竖直)对齐< textarea> [英] Middle (vertically) align text inside a <textarea>
问题描述
这是一个多线搜索框,所以我想要一切在中间对齐。是可能吗?
It's a multiline search-box, so i want everything aligned in the middle. Is it possible?
推荐答案
回到我在问这个问题的日子,我试图实现这与textarea这是真的不可能无脚本。答案是在带有style =vertical-align:middle的表格单元格上添加HTML5的contenteditable =true。如果您的项目允许现代HTML,这是一个相当简单和有效的解决方案。
Back in the days when i was asking this, i tried achieving this with textarea which is really not possible without scripting. The answer was adding HTML5's contenteditable="true" on a table cell with style="vertical-align: middle". If one's project allows modern HTML, this is a rather simple and effective solution.
如果不是添加< table>
和< tr>
和< td>
code>< div> ,您仍然需要其中两个:
If instead of adding <table>
and <tr>
and <td>
to your markup, you would like something regular like a <div>
, you would still need two of them:
<div style="display: table">
<div
style="display: table-cell; vertical-align: middle"
contenteditable="true">
I am vertically aligned
</div>
</div>
这篇关于中(竖直)对齐< textarea>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!