如何将文本区域的标签与该文本方面的中心保持一致?

发布于 2025-01-31 05:10:38 字数 951 浏览 2 评论 0原文

嗨,我试图使文本区域的标签与文本区域集中。

我的设计如下:

我的文本区域行是“ 2”。我正在使用bootstrap col分离器将列分为4和8,因为我想要这样的设计。现在,我试图分配标签数据定义要较低,以完全显示在中心,如下图所示,突出显示了。

我的代码如下:

 <br />
         <div class="row" style="border:solid">
             <div class="col-sm-4" style="text-align:center;background-color:#3abaab;font-size:large;vertical-align: middle; ">Data Definition </div>
  <div class="col-sm-8"><textarea name="id" id="id" cols="45" rows="2">@Model.DD</textarea></div>
         </div>
             <br />

如何解决此问题。请帮助。

Hi I am trying to align the label of the text area to be centralized for the textarea.

My Design as follows:
enter image description here

My text area rows is "2". I am using bootstrap col separator to split the column into 4 and 8, as I want design like this. Now I am trying to assign the label Data Definition to be bit lower to display exactly at the center as shown in image below with highlighted.

enter image description here

My code as follows:

 <br />
         <div class="row" style="border:solid">
             <div class="col-sm-4" style="text-align:center;background-color:#3abaab;font-size:large;vertical-align: middle; ">Data Definition </div>
  <div class="col-sm-8"><textarea name="id" id="id" cols="45" rows="2">@Model.DD</textarea></div>
         </div>
             <br />

How to fix this. Kindly help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一袭水袖舞倾城 2025-02-07 05:10:38

一种总是简单的方法是使div

[appropriate css selector for div containing "Data Definition"] {
  display: flex;
  align-items: center;
  /* if you want to horizontally center as well, then: */
  justify-content: center;
}

垂直居中。

.title {
  width: 200px;
  height: 200px;

  text-align: center;
  background-color: #3abaab;
  font-size: large;
  vertical-align: middle;
  
  display: flex;
  align-items: center;
  justify-content: center;
}
<div class="title">
  Data Definition
</div>

An always simple way is to make the div

[appropriate css selector for div containing "Data Definition"] {
  display: flex;
  align-items: center;
  /* if you want to horizontally center as well, then: */
  justify-content: center;
}

to vertically center them.

.title {
  width: 200px;
  height: 200px;

  text-align: center;
  background-color: #3abaab;
  font-size: large;
  vertical-align: middle;
  
  display: flex;
  align-items: center;
  justify-content: center;
}
<div class="title">
  Data Definition
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文