【发布时间】:2021-09-02 01:10:59
【问题描述】:
我正在尝试创建一个用于空白填充的模板,使用我找到的 HTML 内联元素表单显示 this other answer very useful.
我的主要挑战是我希望表单水平居中并在计算机中占屏幕宽度的 50%,在较小的屏幕设备中为 100%。
我希望我的文本区域与文本垂直对齐。
我最近学习了一些 flex,所以我尝试将它用于父元素(表单)以垂直和水平对齐,但我没有设法达到预期的结果。我在这里错过了什么?
index.html
<body>
<form style="margin: 0; padding: 0; display: flex; align-items: center; width: 50%; justify-content: center;">
<p ><!--style="display: flex; align-items: center;">-->
My name is
<textarea name="name" id="" cols="10" rows="1" placeholder="enter name"></textarea>
and I come from a village called
<textarea name="village" cols="10" rows="1" placeholder="enter village"></textarea>
. In the village of
<textarea name="village" cols="10" rows="1" placeholder="enter village"></textarea>
everybody knows that my name is
<textarea name="name" cols="10" rows="1" placeholder="enter name"></textarea>
.
My name is
<textarea name="name" id="" cols="10" rows="1" placeholder="enter name"></textarea>
and I come from a village called
<textarea name="village" cols="10" rows="1" placeholder="enter village"></textarea>
. In the village of
<textarea name="village" cols="10" rows="1" placeholder="enter village"></textarea>
everybody knows that my name is
<textarea name="name" cols="10" rows="1" placeholder="enter name"></textarea>
.
</p>
</form>
</body>
/static/style.css
textarea {
margin: 0 5px;
background-color: #eff0f1;
}
【问题讨论】: