我怎样才能得到我的

沿 边垂直居中的元素和<文本区域>领域?

发布于 2024-09-13 21:45:11 字数 678 浏览 4 评论 0原文

我无法将 pinputtextarea 元素全部集中在 a 中的 li 元素中我现在正在处理的用户设置区域。现在,只有 inputtextarea 元素在 li 元素中正确居中,而 p 元素则在位于顶部。我尝试将

vertical-align: middle

应用于 li 元素,但失败了。

我的 示例代码链接位于 JS Bin

为了帮助指导您查看我的示例,每个元素的背景颜色如下:

  • p = red
  • li = 青色
  • input & textarea = white

如何让 pinputtextarea 元素全部在 li 元素?

I can't get the p, input and textarea elements all be centered with in a li elements in a user settings area I am working on right now. Right now only the input and textarea elements are being properly centered with in the li elements while the p elements are positioned right at the top. I have tried to apply

vertical-align: middle

to the li element but it failed.

My example code link is here at JS Bin

To help guide you while looking at my example, each element's background color is as follows:

  • p = red
  • li = cyan
  • input & textarea = white

How can I get the p, input and textarea elements all be centered with in a li elements?

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

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

发布评论

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

评论(1

套路撩心 2024-09-20 21:45:11

我了解到像 Twitter 和 Facebook 这样的网站使用以下 HTML 元素创建其设置页面:

  • table
  • tbody
  • tr
  • th
  • td
  • label

所以我决定遵循这个标准实践和 这是我想出的。 CSS 样式不存在,但您可以看到 table 元素及其子元素提供的基本实体结构。请注意table tbody tr th label名称如何自动定位在其包含的表格单元格的中心。如果我需要将它们定位到顶部、底部或基线,那么我需要做的就是将 vertical-align 添加到 label 的父元素,即 >th

这是向第 添加 vertical-align: top; 样式的结果 元素与 textarea 位于同一行。

如果我想将 label 元素水平放置在表格单元格中,那么我只需要要做的就是在第 th 元素上使用 text-align 选择器,然后就可以了。

这是将 text-align: right; 添加到第二个 的结果 在第二个 tr 以及第三个和第四个 tr th 元素中。

I learned that sites like Twitter and Facebook create their settings pages with the following HTML elements:

  • table
  • tbody
  • tr
  • th
  • td
  • label

So I decided to follow this standard practice and this is what I came up with. The CSS styling is not there but you can see that basic solid structure that the table element and its child elements provide. Notice how the table tbody tr th label names automatically are positioned at the center of their containing table cell. And if I need them to be positioned to the top, bottom or baseline than all I need to do is add vertical-align to label's parent element which is th.

This is the result of adding vertical-align: top; styling to the th element in the same row as the textarea.

And if I want to position the label elements horizontally with in the table cell then all I need to do is use the text-alignselector on the th element and presto.

This is the result of adding text-align: right; to the 2nd th in the 2nd tr and the 3rd and 4th tr th elements.

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