css - 空和非空内联 block 基线之间的区别

标签 css

div {
    display: inline-block;
    width: 100px;
    height: 100px;
    background: #aef;
    vertical-align: baseline;
}
base <div>×</div> <div></div> line

空内联 block 的对齐方式与包含文本的 block 不同。这可以通过指定不同的 vertical-align 值来解决,但我想知道为什么会这样。你能指出 CSS 规范的相关部分吗?

最佳答案

来自 CSS2: Line height calculations

vertical-align: baseline — align the baseline of the box with the baseline of the parent box. If the box doesn't have a baseline, align the bottom of the box with the parent's baseline.

关于css - 空和非空内联 block 基线之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8215638/

相关文章:

javascript - jQuery/css让两个div显示在同一行

javascript - 带有子级 div 的省略号

asp.net - 从 HTML 添加到 aspx 文件时,CSS 背景图像属性发生变化

html - 垂直和水平居中数据列表框及其按钮

html - 全屏 li slider 100% 高度不起作用

javascript - 用户单击删除按钮时如何获取当前(添加)按钮

css-tricks.com 媒体查询无法正常工作

html - 将图标字体跨度与文本跨度对齐

javascript - 如何将行值移动到另一个表并重做 html 中的上一个表?

css - 什么是移动网站的好的字体大小调整方法?