【问题标题】:Label beside input (bootstrap form)输入旁边的标签(引导形式)
【发布时间】:2022-01-23 14:44:48
【问题描述】:

我尝试对此进行编码,但没有得到预期的输出,我也尝试使用内联,但它也不起作用。

也许有人可以帮助我显示预期的输出。谢谢

<form action="" method="POST">
                        <!-- Row -->
                        <div class="row gx-4 mb-1">
                        
                        <!-- -->
                         <div class="col-md-6">
                         <label class="small mb-1" for="">Student name</label>
                         <input class="form-control form-control-sm" name="" id="" type="text" value=""/>
                        </div>
                        
                        <!--  -->
                        <div class="col-md-6">
                         <label class="small mb-1" for="">Address</label>
                         <input class="form-control form-control-sm" name="" id="" type="text" value=""/>
                        </div>
                        
                        </div>
                        
                        <!-- Row -->
                        <div class="row gx-4 mb-1">
                        
                        <!-- -->
                         <div class="col-md-6">
                         <label class="small mb-1" for="">ID Number</label>
                         <input class="form-control form-control-sm" name="" id="" type="text" value=""/>
                        </div>
                        
                        <!--  -->
                        <div class="col-md-6">
                         <label class="small mb-1" for="">Email</label>
                         <input class="form-control form-control-sm" name="" id="" type="text" value=""/>
                        </div>
                        
                        </div>
                        
                        
                        </form>

here is the sample result

【问题讨论】:

    标签: html css bootstrap-5 bootstrap-form-helper


    【解决方案1】:

    应该用 2-10 列将 labelinput 包装在 row 中。

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    </head>
    <body>
        <div class="row px-4 mt-4">
            <div class="col-md-6 row mb-3">
                <div class="col-2 col-form-label">
                    Label
                </div>
                <div class="col-10">
                    <input type="text" class="form-control">
                </div>
            </div>
            <div class="col-md-6 row mb-3">
                <div class="col-2 col-form-label">
                    Label
                </div>
                <div class="col-10">
                    <input type="text" class="form-control">
                </div>
            </div>        
        </div>
        <div class="row px-4 mt-4">
            <div class="col-md-6 row mb-3">
                <div class="col-2 col-form-label">
                    Label
                </div>
                <div class="col-10">
                    <input type="text" class="form-control">
                </div>
            </div>
            <div class="col-md-6 row mb-3">
                <div class="col-2 col-form-label">
                    Label
                </div>
                <div class="col-10">
                    <input type="text" class="form-control">
                </div>
            </div>
        </div>
    </body>
    </html>

    您可以根据需要调整填充/边距。

    【讨论】:

      猜你喜欢
      • 2013-07-11
      • 1970-01-01
      • 2022-12-26
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      相关资源
      最近更新 更多