简体   繁体   English

在一个容器中设置表单方法和子元素的样式

[英]Styling form method and child elements in one container

I am trying to have my form element on the top of the container then my child elements right beneath it (new line) but couldn't make it.我试图将我的表单元素放在容器的顶部,然后将我的子元素放在它的正下方(新行),但无法做到。

Please, any idea on how to do that?请,关于如何做到这一点的任何想法?

Update:更新:

I just update my snippet for a better and clearer idea of what I am looking for.我只是更新了我的片段,以便更好、更清楚地了解我在寻找什么。 So, again, I just need to have the submit form (file import) buttons on top and other child elements buttons right below.所以,再一次,我只需要顶部的提交表单(文件导入)按钮和下面的其他子元素按钮。

 form { display: flex; top: 0px; margin:0px; width: 1900px; padding: 0px; align-items: center; }.container { display: flex; top: 5px; margin:20px; border-width: 2px; border-bottom-color:#3300ff; border-bottom-style: solid; width: 1900px; border: 5px solid green; border-radius: .5em; padding: 5px; align-items: center; }.child { margin-bottom:50px; }
 <div class="container"> <form action="getfile2" method="POST" enctype="multipart/form-data" > <font size="10"><pre class="tab"> Import File: </pre></font> <input type="file" name="file"> <input type="submit" value="Submit"> </form> <div class="child"> <div id="slider9" class='slider row1 col1'></div> <div class="my_text"><center> <p>param_1</p> <button class="sliderStateChange">Enable</button> <button id="turn_off_button9">TURN OFF</button> </center></div> </div> <div class="child"> <div id="slider10" class='slider row6 col2'></div> <div class="my_text"><center> <p>param_2</p> <button class="sliderStateChange">Enable</button> <button id="turn_off_button10">TURN OFF</button> </center></div> </div> <div class="child"> <div id="slider11" class='slider row1 col3'></div> <div class="my_text"><center> <p>param_3</p> <button class="sliderStateChange">Enable</button> <button id="turn_off_button11">TURN OFF</button> </center></div> </div> </div>

Adding flex-flow: column nowrap;添加flex-flow: column nowrap; to your .container div will put your .child divs below the <form> element like so:到您的.container div 会将您的.child div 放在<form>元素下方,如下所示:

Note that they are in the middle of your parent, as your parent centers all it's elements with align-items: center;请注意,它们位于您父母的中间,因为您的父母使用align-items: center;所有元素居中。

 form { display: flex; top: 0px; margin: 0px; width: 1900px; padding: 0px; align-items: center; }.container { display: flex; flex-flow: column nowrap; top: 5px; margin: 20px; border-width: 2px; border-bottom-color: #3300ff; border-bottom-style: solid; width: 1900px; border: 5px solid green; border-radius: .5em; padding: 5px; align-items: center; }.child { margin-bottom: 50px; background-color: green; }
 <div class="container"> <form action="getfile2" method="POST" enctype="multipart/form-data"> <font size="10"> <pre class="tab"> Import File: </pre> </font> <input type="file" name="file"> <input type="submit" value="Submit"> </form> <div class="child"> <div id="slider9" class='slider row1 col1'></div> <div class="my_text"> <center> <p>param_1</p> <button class="sliderStateChange">Enable</button> <button id="turn_off_button9">TURN OFF</button> </center> </div> </div> <div class="child"> <div id="slider10" class='slider row6 col2'></div> <div class="my_text"> <center> <p>param_2</p> <button class="sliderStateChange">Enable</button> <button id="turn_off_button10">TURN OFF</button> </center> </div> </div> <div class="child"> <div id="slider11" class='slider row1 col3'></div> <div class="my_text"> <center> <p>param_3</p> <button class="sliderStateChange">Enable</button> <button id="turn_off_button11">TURN OFF</button> </center> </div> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM