简体   繁体   English

如何并排放置一组 div 元素?

[英]How to position a set of div elements side by side?

I have placed two div elements contained in a form.我在一个表单中放置了两个 div 元素。 My aim is to place the second div "App" side by side with the "Status" div like in the mock up below:我的目标是将第二个 div“App”与“Status”div 并排放置,如下面的模型所示:

What I've tried so far is the following, setting the align="right" which positions the div on the extreme right.到目前为止,我尝试过以下操作,设置align="right"将 div 定位在最右侧。

Also I tried setting style="margin-left: which places the second div underneath and too far right of the first div.我还尝试设置style="margin-left:将第二个 div 放在第一个 div 的下方和太远的右侧。

Question:题:

Does anyone know how I can place the second div in line and side by side with the first div?有谁知道我可以一边与第一格放置第二个div的线

Form markup:表单标记:

      <form action="" method="post">
                <div class="form-horizontal">
                    <div class="col-lg-6">


                            <!-- SELECT STATUS STATIC-->
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="Current Status">Status</label>
                                <div class="col-md-8">
                                    <select id="Status" name="Status" onchange="" class=" form-control">
                                        <option value="Down">Down</option>
                                        <option value="Up">Up</option>
                                    </select>
                                </div>
                            </div>


                            <!-- SELECT APP STATIC-->
                            <div class="form-group">
                                <label class="col-md-3 control-label"  for="App">App</label>
                                <div class="col-md-8" >
                                    <select id="App" name="App" onchange="" class=" form-control">
                                        <option value="SAP">SAP</option>
                                        <option value="JAP">JAP</option>
                                    </select>
                                </div>
                            </div>

                    </div>
                </div>
            </form>            <!--END OF FORM ^^-->

You can set both divs to display: inline-block.您可以将两个 div 都设置为显示:inline-block。

.form-group {
  display: inline-block;
}

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

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