html - 多个部分设置为行内 block ,当其中一个部分的文本少行时,它会错位

标签 html css

misaligned section

HTML:

<section id="minibox"><h3>Shop</h3><i>The store module. Manage your products, payment methods and more.</i><br /><a title="Remove" href="#" style="float:right; margin:10px 0 0 10px;" class="content-btn-small">-</a><a href="#" style="float:right; margin:10px 0 0 0;" class="content-btn-small">Edit</a></section>

<section id="minibox"><h3>Comments</h3><i>The comment module. Allows comments on pages you choose.</i><br /><a title="Remove" href="#" style="float:right; margin:10px 0 0 10px;" class="content-btn-small">-</a><a href="#" style="float:right; margin:10px 0 0 0;" class="content-btn-small">Edit</a></section>

<section id="minibox"><h3>Other</h3><i>The store module. Manage your products, payment methods and more.</i><br /><a title="Remove" href="#" style="float:right; margin:10px 0 0 10px;" class="content-btn-small">-</a><a href="#" style="float:right; margin:10px 0 0 0;" class="content-btn-small">Edit</a></section>

<section id="minibox"><h3>Other</h3><i>Test module for layout testing purposes, more text to make the box larger to see how it handles it.</i><br /><a title="Remove" href="#" style="float:right; margin:10px 0 0 10px;" class="content-btn-small">-</a><a href="#" style="float:right; margin:10px 0 0 0;" class="content-btn-small">Edit</a></section>

<section id="minibox"><h3>Other</h3><i>Test module for layout testing purposes, more text to make the box larger to see how it handles it.</i><br /><a title="Remove" href="#" style="float:right; margin:10px 0 0 10px;" class="content-btn-small">-</a><a href="#" style="float:right; margin:10px 0 0 0;" class="content-btn-small">Edit</a></section>

CSS:

#minibox { width: 18%; margin: 10px 1%; padding: 10px; display: inline-block; background: #EEE; text-align:center; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; height:142px; }

当其中一个框的文本少于其他框时,它不会以内联方式显示,所以我尝试添加 min-height/height 认为它会修复它。它使所有框的大小一致,但它仍然将文本较少的框排在一行中。有什么方法可以解决这个问题而不仅仅是添加一个空行吗?

谢谢

最佳答案

vertical-align: top 添加到您的 CSS。附带说明一下,考虑使用类而不是 id 来重复出现样式。

关于html - 多个部分设置为行内 block ,当其中一个部分的文本少行时,它会错位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13456413/

相关文章:

javascript - 将字符串值从一个 html 传递到另一个 (Phonegap)

css - 为 Twitter Bootstrap 调整对象大小

css - Twitter Bootstrap - 自定义页面的解释

javascript - 无法使用 jquery 选择特定元素

PHP - $_FILES 数组为空

html - 屏幕上的过渡元素

html - 当我使用带有 margin-top 或 margin-bottom 的 h1 或 div 时,顶部/底部出现空白

html - CSS - 如何将样式应用于静态生成列表中的第一个元素

javascript - 使用 Javascript (vue.js) 在 iframe 中附加样式

css - bootstrap 3.3.7 如何让列在移动 View 中没有间隙地堆叠在一起?