0

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

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

<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>

这是示例结果

在此处输入图像描述

4

1 回答 1

1

label将and包裹在input2-10中应该可以做到这一点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>

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

于 2022-01-14T07:23:08.453 回答