Textarea Autoheight CSS [英] Textarea Autoheight CSS

查看:128
本文介绍了Textarea Autoheight CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个textarea将保存数据库中的数据。它将被禁用,以便用户不能与它进行交互。

I have a textarea that will hold data from a database. It will be disabled so that the user cannot interact with it.

有一种方法通过css设置高度,以便它适合该区域。 IE:如果只有一行文本,textarea高度只有1行,或者如果有3行文本,textarea高度是3行?

Is there a way to set the height via css so that it fits the area. IE: if there is only one line of text, the textarea height is only 1 row or if there is 3 lines of text, the textarea height is 3 rows?

MVC应用程序的一部分,如果这有帮助。我也使用html.textareafor。

It's part of an MVC application if that helps at all. I'm using the html.textareafor as well.

推荐答案

我能想到的最简单的是:

Simplest I can think of is this:

工作小提琴

div {
   display:inline-block;
   border: solid 1px #000;
   min-height:10px;
   width: 300px;
}

更多选项:

  • Textarea Auto height
  • Textarea to resize based on content length

这篇关于Textarea Autoheight CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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