【发布时间】:2013-04-15 23:31:24
【问题描述】:
我想在 HTML textarea 中使用 white-space CSS 属性。
基本上,如果有人在textarea 中键入带有换行符的一堆文本,然后将此数据提交到MySQL 中存储,我想使用white-space CSS 属性在文本区域中显示这些换行符。但是当我尝试它时,它不起作用,只是将文本全部显示在一个大段落中,没有任何中断或任何东西。有没有办法做到这一点?
<form action="includes/changebio.php" method="post" id="form1">
<textarea id="bio" style="width: 440px;
margin-top:3px;
text-align:left;
margin-left:-2px;
height: 120px;
resize: none;
outline:none;
overflow:scroll;
**white-space:pre-line;**
border: #ccc 1px solid;" textarea name="bio" data-id="bio" maxlength="710" placeholder="<?php echo stripslashes($profile['bio']); ?>"></textarea>
<input type="image" src="assets/img/icons/save-edit.png"class="bio-submit" name="submit" value="submit" id="submit"/>
</form>
【问题讨论】:
-
这个“将文本全部显示在一个大段落中”的“它”是什么?听起来您的问题出在提交的用户输入的 processing 中,而不是在
textarea元素的样式中。该元素,如示例代码所示,没有内容。