不同高度的内联块的对齐问题

发布于 2024-11-29 15:14:36 字数 239 浏览 5 评论 0原文

我试图让此处所示的块彼此对齐,但如果它们的高度不同,由于某种原因,较短的 div 会与容器 div 的底部对齐。这两个 div 都没有任何会导致此行为的填充或边距。我需要做什么才能让它们与 div 顶部对齐?

在此处输入图像描述 在此输入图像描述

I'm trying to get the blocks pictured here to align with each other, but if they are different heights, for some reason the shorter div aligns to the bottom of the container div. Neither div has any sort of padding or margin that would cause this behavior. What do I need to do to get them to align to the top of the div?

enter image description here enter image description here

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

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

发布评论

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

评论(1

凡间太子 2024-12-06 15:14:36

vertical-align:top 在您想要垂直对齐的元素上(而不是在父元素上),因为它们是 display:inline-block

vertical-align:top on the elements that you want to be vertically aligned (not on the parent), as they are display:inline-block.

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