加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lyear_forms_layout.html 28.69 KB
一键复制 编辑 原始数据 按行查看 历史
笔下光年 提交于 2022-11-01 21:00 . 提交代码
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="keywords" content="LightYear,LightYearAdmin,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="Light Year Admin V5是一个基于Bootstrap v5.1.3的后台管理系统的HTML模板。">
<title>布局 - 光年(Light Year Admin V5)后台管理系统模板</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.min.css">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<header class="card-header"><div class="card-title">布局</div></header>
<div class="card-body">
<p>使用我们的表单布局选项为您的表单提供一些结构——从内联到水平再到自定义网格实现</p>
<h6>表单</h6>
<p>每组表单字段都应该驻留在一个 <code>&lt;form&gt;</code> 元素中。 Bootstrap 没有为 <code>&lt;form&gt;</code> 元素提供默认样式,但是默认提供了一些强大的浏览器功能。</p>
<ul>
<li>浏览器表单的新手?考虑查看 MDN 表单文档以获取可用属性的概述和完整列表。</li>
<li><code>&lt;form&gt;</code> 中的 <code>&lt;button&gt;</code> 默认为 <code>type="submit"</code>,因此要尽量具体并始终包含类型。</li>
<li>您可以使用 <code>&lt;form&gt;</code> 上的 <code>disabled</code> 属性禁用表单中的每个表单元素。</li>
</ul>
<p>由于 Bootstrap 将 <code>display: block</code><code>width: 100%</code> 应用于我们几乎所有的表单控件,因此默认情况下表单将垂直堆叠。可以使用其他类来根据每个表单更改此布局。</p>
<h6>实用程序</h6>
<p>边距实用程序是向表单添加一些结构的最简单方法。它们提供标签、控件、可选表单文本和表单验证消息的基本分组。我们建议坚持使用最低边距实用程序,并在整个表单中使用单一方向以保持一致性。</p>
<p>随意使用 <code>&lt;fieldset&gt;</code>s、<code>&lt;div&gt;</code>s 或几乎任何其他元素来构建您喜欢的表单。</p>
<div class="border-example">
<div class="mb-3">
<label for="formGroupExampleInput" class="form-label">label示例</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="输入占位符示例">
</div>
<div class="mb-3">
<label for="formGroupExampleInput2" class="form-label">另一个label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="另一个输入占位符">
</div>
</div>
<pre>&lt;div class="mb-3"&gt;
&lt;label for="formGroupExampleInput" class="form-label"&gt;label示例&lt;/label&gt;
&lt;input type="text" class="form-control" id="formGroupExampleInput" placeholder="输入占位符示例"&gt;
&lt;/div&gt;
&lt;div class="mb-3"&gt;
&lt;label for="formGroupExampleInput2" class="form-label"&gt;另一个label&lt;/label&gt;
&lt;input type="text" class="form-control" id="formGroupExampleInput2" placeholder="另一个输入占位符"&gt;
&lt;/div&gt;</pre>
<h6>表格网格</h6>
<p>使用我们的网格类可以构建更复杂的表单。将这些用于需要多列、不同宽度和其他对齐选项的表单布局。需要启用 <code>$enable-grid-classes</code> Sass 变量(默认启用)。</p>
<div class="border-example">
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="First name" aria-label="姓名">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name" aria-label="姓氏">
</div>
</div>
</div>
<pre>&lt;div class="row"&gt;
&lt;div class="col"&gt;
&lt;input type="text" class="form-control" placeholder="First name" aria-label="姓名"&gt;
&lt;/div&gt;
&lt;div class="col"&gt;
&lt;input type="text" class="form-control" placeholder="Last name" aria-label="姓氏"&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<h6>边距</h6>
<p>通过添加边距修饰符类,您可以控制边距宽度以及内联和块方向。还需要启用 <code>$enable-grid-classes</code> Sass 变量(默认启用)。</p>
<div class="border-example">
<div class="row g-3">
<div class="col">
<input type="text" class="form-control" placeholder="First name" aria-label="姓名">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name" aria-label="姓氏">
</div>
</div>
</div>
<pre>&lt;div class="row g-3"&gt;
&lt;div class="col"&gt;
&lt;input type="text" class="form-control" placeholder="First name" aria-label="姓名"&gt;
&lt;/div&gt;
&lt;div class="col"&gt;
&lt;input type="text" class="form-control" placeholder="Last name" aria-label="姓氏"&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>还可以使用网格系统创建更复杂的布局。</p>
<div class="border-example">
<form class="row g-3">
<div class="col-md-6">
<label for="inputEmail4" class="form-label">邮箱</label>
<input type="email" class="form-control" id="inputEmail4">
</div>
<div class="col-md-6">
<label for="inputPassword4" class="form-label">密码</label>
<input type="password" class="form-control" id="inputPassword4">
</div>
<div class="col-12">
<label for="inputAddress" class="form-label">地址</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
</div>
<div class="col-12">
<label for="inputAddress2" class="form-label">地址 2</label>
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
</div>
<div class="col-md-6">
<label for="inputCity" class="form-label">城市</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="col-md-4">
<label for="inputState" class="form-label">State</label>
<select id="inputState" class="form-select">
<option selected>请选择...</option>
<option>...</option>
</select>
</div>
<div class="col-md-2">
<label for="inputZip" class="form-label">邮编</label>
<input type="text" class="form-control" id="inputZip">
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label" for="gridCheck">
保持登录
</label>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">登录</button>
</div>
</form>
</div>
<pre>&lt;form class="row g-3"&gt;
&lt;div class="col-md-6"&gt;
&lt;label for="inputEmail4" class="form-label"&gt;邮箱&lt;/label&gt;
&lt;input type="email" class="form-control" id="inputEmail4"&gt;
&lt;/div&gt;
&lt;div class="col-md-6"&gt;
&lt;label for="inputPassword4" class="form-label"&gt;密码&lt;/label&gt;
&lt;input type="password" class="form-control" id="inputPassword4"&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;label for="inputAddress" class="form-label"&gt;地址&lt;/label&gt;
&lt;input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St"&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;label for="inputAddress2" class="form-label"&gt;地址 2&lt;/label&gt;
&lt;input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor"&gt;
&lt;/div&gt;
&lt;div class="col-md-6"&gt;
&lt;label for="inputCity" class="form-label"&gt;城市&lt;/label&gt;
&lt;input type="text" class="form-control" id="inputCity"&gt;
&lt;/div&gt;
&lt;div class="col-md-4"&gt;
&lt;label for="inputState" class="form-label"&gt;State&lt;/label&gt;
&lt;select id="inputState" class="form-select"&gt;
&lt;option selected&gt;请选择...&lt;/option&gt;
&lt;option&gt;...&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;div class="col-md-2"&gt;
&lt;label for="inputZip" class="form-label"&gt;邮编&lt;/label&gt;
&lt;input type="text" class="form-control" id="inputZip"&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="checkbox" id="gridCheck"&gt;
&lt;label class="form-check-label" for="gridCheck"&gt;
保持登录
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;button type="submit" class="btn btn-primary"&gt;登录&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;</pre>
<h5>水平形式</h5>
<p>通过将 <code>.row</code> 类添加到表单组并使用 <code>.col-*-*</code> 类指定标签和控件的宽度,使用网格创建水平表单。请务必将 <code>.col-form-label</code> 添加到您的 <code>&lt;label&gt;</code> 中,以便它们与其关联的表单控件垂直居中。</p>
<p>有时,您可能需要使用边距或填充实用程序来创建所需的完美对齐。例如,我们移除了堆叠单选输入标签上的 <code>padding-top</code>,以更好地对齐文本基线。</p>
<div class="border-example">
<form>
<div class="row mb-3">
<label for="inputEmail3" class="col-sm-2 col-form-label">邮箱</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3">
</div>
</div>
<div class="row mb-3">
<label for="inputPassword3" class="col-sm-2 col-form-label">密码</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3">
</div>
</div>
<fieldset class="row mb-3">
<legend class="col-form-label col-sm-2 pt-0">单选框</legend>
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
<label class="form-check-label" for="gridRadios1">
第一个单选框
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
<label class="form-check-label" for="gridRadios2">
第二个单选框
</label>
</div>
<div class="form-check disabled">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
<label class="form-check-label" for="gridRadios3">
第三个已禁用的单选框
</label>
</div>
</div>
</fieldset>
<div class="row mb-3">
<div class="col-sm-10 offset-sm-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck1">
<label class="form-check-label" for="gridCheck1">
复选框示例
</label>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">登录</button>
</form>
</div>
<pre>&lt;form&gt;
&lt;div class="row mb-3"&gt;
&lt;label for="inputEmail3" class="col-sm-2 col-form-label"&gt;邮箱&lt;/label&gt;
&lt;div class="col-sm-10"&gt;
&lt;input type="email" class="form-control" id="inputEmail3"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="row mb-3"&gt;
&lt;label for="inputPassword3" class="col-sm-2 col-form-label"&gt;密码&lt;/label&gt;
&lt;div class="col-sm-10"&gt;
&lt;input type="password" class="form-control" id="inputPassword3"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;fieldset class="row mb-3"&gt;
&lt;legend class="col-form-label col-sm-2 pt-0"&gt;单选框&lt;/legend&gt;
&lt;div class="col-sm-10"&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked&gt;
&lt;label class="form-check-label" for="gridRadios1"&gt;
第一个单选框
&lt;/label&gt;
&lt;/div&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2"&gt;
&lt;label class="form-check-label" for="gridRadios2"&gt;
第二个单选框
&lt;/label&gt;
&lt;/div&gt;
&lt;div class="form-check disabled"&gt;
&lt;input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled&gt;
&lt;label class="form-check-label" for="gridRadios3"&gt;
第三个已禁用的单选框
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/fieldset&gt;
&lt;div class="row mb-3"&gt;
&lt;div class="col-sm-10 offset-sm-2"&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="checkbox" id="gridCheck1"&gt;
&lt;label class="form-check-label" for="gridCheck1"&gt;
复选框示例
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;button type="submit" class="btn btn-primary"&gt;登录&lt;/button&gt;
&lt;/form&gt;</pre>
<h6>水平表单标签大小</h6>
<p>请务必使用 <code>.col-form-label-sm</code><code>.col-form-label-lg</code> 到您的 <code>&lt;label&gt;</code><code>&lt;legend&gt;</code> 以跟随标签的大小 <code>.form-control-lg</code><code>.form-control-sm</code></p>
<div class="border-example">
<div class="row mb-3">
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">邮箱</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
</div>
</div>
<div class="row mb-3">
<label for="colFormLabel" class="col-sm-2 col-form-label">邮箱</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
</div>
</div>
<div class="row">
<label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">邮箱</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
</div>
</div>
</div>
<pre>&lt;div class="row mb-3"&gt;
&lt;label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm"&gt;邮箱&lt;/label&gt;
&lt;div class="col-sm-10"&gt;
&lt;input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="row mb-3"&gt;
&lt;label for="colFormLabel" class="col-sm-2 col-form-label"&gt;邮箱&lt;/label&gt;
&lt;div class="col-sm-10"&gt;
&lt;input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="row"&gt;
&lt;label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg"&gt;邮箱&lt;/label&gt;
&lt;div class="col-sm-10"&gt;
&lt;input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg"&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<h6>列大小</h6>
<p>如前面的示例所示,我们的网格系统允许您在 <code>.row</code> 中放置任意数量的 <code>.col</code>。他们将在它们之间平均分配可用宽度。您还可以选择列的子集以占用更多或更少的空间,而其余的 <code>.cols</code> 将其余部分平均分配,具有特定的列类,例如 <code>.col-sm-7</code></p>
<div class="border-example">
<div class="row g-3">
<div class="col-sm-7">
<input type="text" class="form-control" placeholder="城市" aria-label="城市">
</div>
<div class="col-sm">
<input type="text" class="form-control" placeholder="乡镇" aria-label="乡镇">
</div>
<div class="col-sm">
<input type="text" class="form-control" placeholder="邮编" aria-label="邮编">
</div>
</div>
</div>
<pre>&lt;div class="row g-3"&gt;
&lt;div class="col-sm-7"&gt;
&lt;input type="text" class="form-control" placeholder="城市" aria-label="城市"&gt;
&lt;/div&gt;
&lt;div class="col-sm"&gt;
&lt;input type="text" class="form-control" placeholder="乡镇" aria-label="乡镇"&gt;
&lt;/div&gt;
&lt;div class="col-sm"&gt;
&lt;input type="text" class="form-control" placeholder="邮编" aria-label="邮编"&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<h6>自动调整大小</h6>
<p>下面的示例使用 <code>flexbox</code> 实用程序将内容垂直居中并将 <code>.col</code> 更改为 <code>.col-auto</code> 以便您的列只占用所需的空间。换句话说,列大小本身基于内容。</p>
<div class="border-example">
<form class="row gy-2 gx-3 align-items-center">
<div class="col-auto">
<label class="visually-hidden" for="autoSizingInput">姓名</label>
<input type="text" class="form-control" id="autoSizingInput" placeholder="乔峰">
</div>
<div class="col-auto">
<label class="visually-hidden" for="autoSizingInputGroup">用户名</label>
<div class="input-group">
<div class="input-group-text">@</div>
<input type="text" class="form-control" id="autoSizingInputGroup" placeholder="用户名">
</div>
</div>
<div class="col-auto">
<label class="visually-hidden" for="autoSizingSelect">爱好</label>
<select class="form-select" id="autoSizingSelect">
<option selected>请选择...</option>
<option value="1">篮球</option>
<option value="2">足球</option>
<option value="3">羽毛球</option>
</select>
</div>
<div class="col-auto">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autoSizingCheck">
<label class="form-check-label" for="autoSizingCheck">
记住我
</label>
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
<pre>&lt;form class="row gy-2 gx-3 align-items-center"&gt;
&lt;div class="col-auto"&gt;
&lt;label class="visually-hidden" for="autoSizingInput"&gt;姓名&lt;/label&gt;
&lt;input type="text" class="form-control" id="autoSizingInput" placeholder="乔峰"&gt;
&lt;/div&gt;
&lt;div class="col-auto"&gt;
&lt;label class="visually-hidden" for="autoSizingInputGroup"&gt;用户名&lt;/label&gt;
&lt;div class="input-group"&gt;
&lt;div class="input-group-text"&gt;@&lt;/div&gt;
&lt;input type="text" class="form-control" id="autoSizingInputGroup" placeholder="用户名"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-auto"&gt;
&lt;label class="visually-hidden" for="autoSizingSelect"&gt;爱好&lt;/label&gt;
&lt;select class="form-select" id="autoSizingSelect"&gt;
&lt;option selected&gt;请选择...&lt;/option&gt;
&lt;option value="1"&gt;篮球&lt;/option&gt;
&lt;option value="2"&gt;足球&lt;/option&gt;
&lt;option value="3"&gt;羽毛球&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;div class="col-auto"&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="checkbox" id="autoSizingCheck"&gt;
&lt;label class="form-check-label" for="autoSizingCheck"&gt;
记住我
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-auto"&gt;
&lt;button type="submit" class="btn btn-primary"&gt;提交&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;</pre>
<p>然后,您可以再次将其与特定于大小的列类重新混合。</p>
<div class="border-example">
<form class="row gx-3 gy-2 align-items-center">
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeInputName">姓名</label>
<input type="text" class="form-control" id="specificSizeInputName" placeholder="段誉">
</div>
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeInputGroupUsername">用户名</label>
<div class="input-group">
<div class="input-group-text">@</div>
<input type="text" class="form-control" id="specificSizeInputGroupUsername" placeholder="用户名">
</div>
</div>
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeSelect">爱好</label>
<select class="form-select" id="specificSizeSelect">
<option selected>请选择...</option>
<option value="1">六脉神剑</option>
<option value="2">一指禅</option>
<option value="3">落英神剑</option>
</select>
</div>
<div class="col-auto">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autoSizingCheck2">
<label class="form-check-label" for="autoSizingCheck2">
记住我
</label>
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
<pre>&lt;form class="row gx-3 gy-2 align-items-center"&gt;
&lt;div class="col-sm-3"&gt;
&lt;label class="visually-hidden" for="specificSizeInputName"&gt;姓名&lt;/label&gt;
&lt;input type="text" class="form-control" id="specificSizeInputName" placeholder="段誉"&gt;
&lt;/div&gt;
&lt;div class="col-sm-3"&gt;
&lt;label class="visually-hidden" for="specificSizeInputGroupUsername"&gt;用户名&lt;/label&gt;
&lt;div class="input-group"&gt;
&lt;div class="input-group-text"&gt;@&lt;/div&gt;
&lt;input type="text" class="form-control" id="specificSizeInputGroupUsername" placeholder="用户名"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-sm-3"&gt;
&lt;label class="visually-hidden" for="specificSizeSelect"&gt;爱好&lt;/label&gt;
&lt;select class="form-select" id="specificSizeSelect"&gt;
&lt;option selected&gt;请选择...&lt;/option&gt;
&lt;option value="1"&gt;六脉神剑&lt;/option&gt;
&lt;option value="2"&gt;一指禅&lt;/option&gt;
&lt;option value="3"&gt;落英神剑&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;div class="col-auto"&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="checkbox" id="autoSizingCheck2"&gt;
&lt;label class="form-check-label" for="autoSizingCheck2"&gt;
记住我
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-auto"&gt;
&lt;button type="submit" class="btn btn-primary"&gt;提交&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;</pre>
<h6>内联表单</h6>
<p>使用 <code>.row-cols-*</code> 类创建响应式水平布局。通过添加排水沟修饰符类,我们将在水平和垂直方向上拥有排水沟。在狭窄的移动视口上,<code>.col-12</code> 有助于堆叠表单控件等。 <code>.align-items-center</code> 将表单元素对齐到中间,使 <code>.form-checkbox</code> 正确对齐。</p>
<div class="border-example">
<form class="row row-cols-lg-auto g-3 align-items-center">
<div class="col-12">
<label class="visually-hidden" for="inlineFormInputGroupUsername">用户名</label>
<div class="input-group">
<div class="input-group-text">@</div>
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="用户名">
</div>
</div>
<div class="col-12">
<label class="visually-hidden" for="inlineFormSelectPref">爱好</label>
<select class="form-select" id="inlineFormSelectPref">
<option selected>请选择...</option>
<option value="1">天龙八部</option>
<option value="2">神雕侠侣</option>
<option value="3">倚天屠龙记</option>
</select>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="inlineFormCheck">
<label class="form-check-label" for="inlineFormCheck">
记住我
</label>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
<pre>&lt;form class="row row-cols-lg-auto g-3 align-items-center"&gt;
&lt;div class="col-12"&gt;
&lt;label class="visually-hidden" for="inlineFormInputGroupUsername"&gt;用户名&lt;/label&gt;
&lt;div class="input-group"&gt;
&lt;div class="input-group-text"&gt;@&lt;/div&gt;
&lt;input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="用户名"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;label class="visually-hidden" for="inlineFormSelectPref"&gt;爱好&lt;/label&gt;
&lt;select class="form-select" id="inlineFormSelectPref"&gt;
&lt;option selected&gt;请选择...&lt;/option&gt;
&lt;option value="1"&gt;天龙八部&lt;/option&gt;
&lt;option value="2"&gt;神雕侠侣&lt;/option&gt;
&lt;option value="3"&gt;倚天屠龙记&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;div class="form-check"&gt;
&lt;input class="form-check-input" type="checkbox" id="inlineFormCheck"&gt;
&lt;label class="form-check-label" for="inlineFormCheck"&gt;
记住我
&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="col-12"&gt;
&lt;button type="submit" class="btn btn-primary"&gt;提交&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;</pre>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化