简体   繁体   English

在同一行标记并选择

[英]Label and select on the same line

How can I put my label and my select on the same line in case of this code?在此代码的情况下,如何将我的标签和我的选择放在同一行?

<div class="form-group">
    <div>
    <label>Filtrar por Categoria:</label>
       <div id="select-categories"></div>
    </div>
 </div>

Javascript: Javascript:

$("#select-categories").each( function ( i ) {
                    var select = $('<select class="form-control"><option value=""></option></select>')
                        .appendTo( $(this).empty() )
                        .on( 'change', function () {
                            table.column( [2] )
                                .search( $(this).val() )
                                .draw();
                        } );

                    table.column([2]).data().unique().sort().each( function ( d, j ) {
                        select.append( '<option value="'+d+'">'+d+'</option>' )
                    } );
                } );

You may set your display to inline-block as in the snippet below.您可以将显示设置为 inline-block,如下面的代码片段所示。 Another good way is to use the Boostrap's column or grid systems .另一个好方法是使用Boostrap 的列或网格系统 By the way, your JavaScript has references to html elements that you never defined.顺便说一下,您的 JavaScript 引用了您从未定义的 html 元素。 Hence, I did not use it.因此,我没有使用它。 In addition, your label was blank to I added some text for testing.另外,你的标签是空白的,我添加了一些文本进行测试。

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form-group"> <div> <label style="display: inline-block;">Filtrar por Categoria:</label> <div style="display: inline-block;" id="select-categories">Label</div> </div> </div>

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

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