如何在文本区域中垂直居中放置文本? [英] How to vertically center text in textarea?

查看:110
本文介绍了如何在文本区域中垂直居中放置文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使在文本区域中输入的宽度和高度已知的文本垂直居中?我有一个固定大小的文本区域,应在其中键入文本,并且我希望文本在键入时从中心开始。水平居中可以通过text-align:center来完成,但是我找不到任何水平对齐的方法。

Is there a way to vertically center text entered in textarea with known width and height? I have a fixed-sized textarea where text should be typed in and I want the text to start from the center while you type it. Horizontal centering could be done with text-align:center, but I cant find any way to align horizontally.

推荐答案

我认为你无法直接进行垂直对齐。您应该在文本区域上再创建一个div,并使用它使文本垂直对齐,然后将用户输入的内容输入到textarea,然后使用JS将其传输到div。

I think you cannot do the vertical alignment directly. You should make another div over the text area and use it to make text vertically aligned and take the inputs from user to the textarea and transfer it to the div using the JS.

并使文本区域仅不可见。

And make the textarea invisible only.

这篇关于如何在文本区域中垂直居中放置文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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