我正在嘗試使用flexbox
創建一個form
,它將包含兩行代碼。如何使用flexbox創建自定義窗體?
在第一個,所有的inputs
和內容將被顯示。在第二個,我想顯示提交button
。
+----------------+--------------------------+
| CONTENT | INPUTS |
+----------------+--------------------------+
| SUBMIT BUTTON |
+-------------------------------------------+
這裏是我的代碼:
html, body{
width: 100%;
margin: 0;
}
#content{
display: flex;
}
#divInside{
position: relative;
width: 200px;
height: 155px;
text-align: center;
background-color: red;
color: white;
margin: 10px;
}
#customForm{
display: flex;
justify-content: center;
align-items: center;
}
#wrapperName{
flex: 1;
}
<div id="content">
<form id="customForm" action="whatever" method="post">
<div id="divInside"></div>
<div id="wrapperName">
<input class="textForm" type="text" name="name" placeholder="Name"><br>
<input class="textForm" type="text" name="description" placeholder="Description"><br>
</div>
<input id="buttonLogin" type="submit" value="Submit">
</form>
</div>
我試圖包裹在一個DIV和內容在另一個inputs
填寫完整的線,但是,作爲第一個div( #divInside
)有一個固定的width
,我不知道如何使其他div(#wrapperName
)填充行的其餘部分,並強制button
移動到下一個線。
如何強制button
到下一行?
在此先感謝!
位置屬性是與'absolute'定位對準內容DIV中的一些元素(這裏我減少代碼量)。謝謝你的回答!這與我所尋找的相似,但不完全相同。無論如何,隨着你的解決方案,你讓我清楚我的想法,並得到它:) –
不客氣。您可以通過啓用容器上的「包裝」並使項目太寬以適合當前行來強制Flex項目到下一行。 –
是的,我以前用過它,但我忘了它。再次感謝您拯救我的生命:) –