需要将复选框下移一点。

huangapple go评论70阅读模式
英文:

I need to move down CheckBox a bit

问题

我的意图是让复选框与输入框和按钮居中对齐。
我尝试在 "form-check" 中使用 "align-center" 类,但不起作用。
有人可以为我提供一种方法吗?
以下是我的代码。

<form method="get" asp-controller="Permit" asp-action="FindPermitNumber" class="row g-3 mt-3">   
	@if (string.IsNullOrEmpty(Model.searchText))
	{
		<div class="col-md-3">
			<input type="text" class="form-control" placeholder="Number" name="searchText" />
		</div>
	}
	else
	{
		<div class="col-md-3">
			<input type="text" class="form-control" placeholder="Number" value="@Model.searchText" name="searchText" />
		</div>
	}

	<div class="col-md-3">
		<div class="form-check align-center">
			<input class="form-check-input" type="checkbox" id="autoSizingCheck" name="isActive" asp-for="@Model.isActive">
			<label class="form-check-label" for="autoSizingCheck">
				Cancel
			</label>
		</div>
	</div>       

	<div class="col-md-3">
		<button formmethod="get" class="btn btn-primary" asp-controller="Permit" asp-action="FindPermitNumber"><i class="fa-solid fa-magnifying-glass fa-lg"></i></button>
	</div>
</form>
英文:

需要将复选框下移一点。
My intention is to have the checkbox aligned in the middle of Input and Button.
I try to use class align-center in "form-check" but not work.
Can anyone suggest a way for me?
This below is my code.

&lt;form method=&quot;get&quot; asp-controller=&quot;Permit&quot; asp-action=&quot;FindPermitNumber&quot; class=&quot;row g-3 mt-3&quot;&gt;   
@if (string.IsNullOrEmpty(Model.searchText))
{
	&lt;div class=&quot;col-md-3&quot;&gt;
		&lt;input type=&quot;text&quot; class=&quot;form-control&quot; placeholder=&quot;Number&quot; name=&quot;searchText&quot; /&gt;
	&lt;/div&gt;
}
else
{
	&lt;div class=&quot;col-md-3&quot;&gt;
		&lt;input type=&quot;text&quot; class=&quot;form-control&quot; placeholder=&quot;Number&quot; value=&quot;@Model.searchText&quot; name=&quot;searchText&quot; /&gt;
	&lt;/div&gt;
}

&lt;div class=&quot;col-md-3&quot;&gt;
	&lt;div class=&quot;form-check&quot;&gt;
		&lt;input class=&quot;form-check-input&quot; type=&quot;checkbox&quot; id=&quot;autoSizingCheck&quot; name=&quot;isActive&quot; asp-for=&quot;@Model.isActive&quot;&gt;
		&lt;label class=&quot;form-check-label&quot; for=&quot;autoSizingCheck&quot;&gt;
			Cancel
		&lt;/label&gt;
	&lt;/div&gt;
&lt;/div&gt;       

&lt;div class=&quot;col-md-3&quot;&gt;
	&lt;button formmethod=&quot;get&quot; class=&quot;btn btn-primary&quot; asp-controller=&quot;Permit&quot; asp-action=&quot;FindPermitNumber&quot;&gt;&lt;i class=&quot;fa-solid fa-magnifying-glass fa-lg&quot;&gt;&lt;/i&gt;&lt;/button&gt;
&lt;/div&gt;

</form>

答案1

得分: 2

您可以将.align-items-center类添加到您的form.row

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<form method="get" class="row g-3 mt-3 align-items-center">   
  <div class="col-3">
      <input type="text" class="form-control" placeholder="Number" />
  </div>

  <div class="col-3">
      <div class="form-check">
          <input class="form-check-input" type="checkbox" id="autoSizingCheck" />
          <label class="form-check-label" for="autoSizingCheck">
              Cancel
          </label>
      </div>
  </div>
</form>
英文:

You can add the .align-items-center class to your form.row :

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;form method=&quot;get&quot; class=&quot;row g-3 mt-3 align-items-center&quot;&gt;   
  &lt;div class=&quot;col-3&quot;&gt;
      &lt;input type=&quot;text&quot; class=&quot;form-control&quot; placeholder=&quot;Number&quot; /&gt;
  &lt;/div&gt;

  &lt;div class=&quot;col-3&quot;&gt;
      &lt;div class=&quot;form-check&quot;&gt;
          &lt;input class=&quot;form-check-input&quot; type=&quot;checkbox&quot; id=&quot;autoSizingCheck&quot; /&gt;
          &lt;label class=&quot;form-check-label&quot; for=&quot;autoSizingCheck&quot;&gt;
              Cancel
          &lt;/label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
&lt;/form&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年6月19日 17:37:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定