html - 如何在标签后向textarea添加换行符

标签 html css

我正在尝试从 Microsoft Word 中获取以下模式:
enter image description here
在 HTML 中我得到:
enter image description here
我如何以 textarea 在标签之后的方式对其进行编码,例如上面 word 中的可视化?

<!DOCTYPE html>
<html lang = "en">
<head>
    <meta charset = "UTF-8">
    <title>testform</title>
    <link rel = "stylesheet" href = "test2.css">
</head>

<body>
    <div class = "entity">
        <label >Enter your address</label>
        <textarea id = "addr_out"></textarea>
    </div>
</body>

最佳答案

这可以通过以下几种方式完成:
(旧黑客)将添加 <br>在标签之后,但我不建议这样做:

<label >Enter your address</label><br/>
或者您也可以将标签和文本区域包装在不同的 div 上。考虑到 div 是全宽的:
<div class = "entity">
   <label >Enter your address</label>
</div>
<div class = "entity">
   <textarea id = "addr_out"></textarea>
</div>
或者你可以在 css 上做,要么使标签宽度 100% :
textarea {
  width: 100%;
}
或制作 .entity使用 flex :
.entity {
  display: flex;
}

关于html - 如何在标签后向textarea添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64385730/

相关文章:

html - Thickbox 3.1 IE8 滚动问题

html - Bootstrap : center the title on the navbar and move logout button right

html - 当 parent 长大/缩小时广泛的 div child

html - 背景颜色 - 适用于 IE6、IE7

html - 如何将所有 li 元素移动到 <ul> 元素的左侧?

html - 如何给 li before 属性添加样式

html - 在不能绝对定位的 div 上使用 z 索引?

javascript - 单击单选按钮后如何自动添加颜色?

css - 无法在 html 中创建响应部分

javascript - 仅为可见元素插入编号