【问题标题】:Bootstrap spacing issue引导间距问题
【发布时间】:2021-03-18 03:19:46
【问题描述】:

我正在尝试使用 Bootstrap 从头开始​​制作申请表。除了这个问题,一切都很好。这里的问题是 ID 为 officeaddress 的元素在加载时在 HTML 页面上不可见。我尝试使用 Bootstrap 的my 类,还尝试在其间添加换行符。然而没有结果。特附上代码供大家参考。

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Parent's details</title>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/css/bootstrap.min.css">

</head>

<body>
    <div class="container"> <br>

        <h1 class="text-center">Your Parent's details</h1>

        <form>
            <div class="form-row">
                <div class="form-group col-md-6 ">
                    <label for="fathername">Father's name: </label>
                    <input type="text" class="form-control" id="fathername">
                </div>
                <div class="form-group col-md-6">
                    <label for="mothername">Mother's name: </label>
                    <input type="text" class="form-control" id="mothername">
                </div>
                <div class="form-group col-md-6">
                    <label for="fatherno">Father's no. : </label>
                    <input type="number" class="form-control" id="fatherno">
                </div>
                <div class="form-group col-md-6">
                    <label for="motherno">Mother's no. : </label>
                    <input type="number" class="form-control" id="motherno">
                </div>
                <div class="form-group col-md-6">
                    <label for="fathermail">Father's mail ID : </label>
                    <input type="email" class="form-control" id="fathermail">
                </div>
                <div class="form-group col-md-6">
                    <label for="mothermail">Mother's mail ID : </label>
                    <input type="email" class="form-control" id="mothermail">
                </div>
            </div>

            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="annualincome">Annual Income:</label>
                    <select id="annualincome" class="form-control">
                        <option selected>Select:</option>
                        <option value="&lt;50000">&lt;50,000</option>
                        <option value="&gt;50000 and &lt;200000"> &gt;50,000 and &lt;2,00,000</option>
                        <option value="&gt;200000 and &lt;500000"> &gt;2,00,000 and &lt;5,00,000</option>
                        <option value="&gt;500000 and &lt;800000"> &gt;5,00,000 and &lt;8,00,000</option>
                        <option value="&gt;800000 and &lt;1000000"> &gt;8,00,000 and &lt;10,00,000</option>
                        <option value="&gt;1000000 and &lt;1200000"> &gt;10,00,000 and &lt;12,00,000</option>
                        <option value="&gt;1200000"> &gt;1200000</option>
                </div>
            </div>

            <div class="form-group col-md-6">
                <label for="officeaddress">Office Address line 1</label>
                <input type="text" class="form-control" id="pfficeaddress">
            </div>
            <div class="form-group col-md-6">
                <label for="officeaddress2">Office Address line 2</label>
                <input type="text" class="form-control" id="officeaddress2">
            </div>
            <div class="form-group col-md-6">
                <label for="officeno">Office no. : </label>
                <input type="number" class="form-control" id="officeno">
            </div>
        </form>

        <a href="educational.html">Proceed to enter educational details</a>
</body>

</html>

【问题讨论】:

  • 离题:您在底部缺少一个结束 div 标记,并且不应将换行元素用于布局间距。
  • 错字:pfficeaddress
  • 您还缺少一个结束 select 标记。我建议更好的编辑器设置或通过 HTML 验证器运行。
  • 是的。我刚刚意识到我错过了select 标签。在发布问题之前我没有注意到它。应尽量不要再重复同样的事情。感谢您的快速回复:)
  • 随时删除您的问题以恢复声誉积分。

标签: html web frontend bootstrap-5


【解决方案1】:

关于“年收入”类,您缺少“选择”的结束标记。

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Parent's details</title>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/css/bootstrap.min.css">

</head>

<body>
    <div class="container"> <br>

        <h1 class="text-center">Your Parent's details</h1>

        <form>
            <div class="form-row">
                <div class="form-group col-md-6 ">
                    <label for="fathername">Father's name: </label>
                    <input type="text" class="form-control" id="fathername">
                </div>
                <div class="form-group col-md-6">
                    <label for="mothername">Mother's name: </label>
                    <input type="text" class="form-control" id="mothername">
                </div>
                <div class="form-group col-md-6">
                    <label for="fatherno">Father's no. : </label>
                    <input type="number" class="form-control" id="fatherno">
                </div>
                <div class="form-group col-md-6">
                    <label for="motherno">Mother's no. : </label>
                    <input type="number" class="form-control" id="motherno">
                </div>
                <div class="form-group col-md-6">
                    <label for="fathermail">Father's mail ID : </label>
                    <input type="email" class="form-control" id="fathermail">
                </div>
                <div class="form-group col-md-6">
                    <label for="mothermail">Mother's mail ID : </label>
                    <input type="email" class="form-control" id="mothermail">
                </div>
            </div>

            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="annualincome">Annual Income:</label>
                    <select id="annualincome" class="form-control">
                        <option selected>Select:</option>
                        <option value="&lt;50000">&lt;50,000</option>
                        <option value="&gt;50000 and &lt;200000"> &gt;50,000 and &lt;2,00,000</option>
                        <option value="&gt;200000 and &lt;500000"> &gt;2,00,000 and &lt;5,00,000</option>
                        <option value="&gt;500000 and &lt;800000"> &gt;5,00,000 and &lt;8,00,000</option>
                        <option value="&gt;800000 and &lt;1000000"> &gt;8,00,000 and &lt;10,00,000</option>
                        <option value="&gt;1000000 and &lt;1200000"> &gt;10,00,000 and &lt;12,00,000</option>
                        <option value="&gt;1200000"> &gt;1200000</option>
                        </select>
                </div>
            </div>
            
            <div class="form-group col-md-6">
                <label for="officeaddress">Office Address line 1</label>
                <input type="text" class="form-control" id="pfficeaddress">
            </div>
            <div class="form-group col-md-6">
                <label for="officeaddress2">Office Address line 2</label>
                <input type="text" class="form-control" id="officeaddress2">
            </div>
            <div class="form-group col-md-6">
                <label for="officeno">Office no. : </label>
                <input type="number" class="form-control" id="officeno">
            </div>
        </form>

        <a href="educational.html">Proceed to enter educational details</a>
</body>

</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 2018-01-20
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多