gpt4 book ai didi

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

转载 作者:技术小花猫 更新时间:2023-10-29 10:25:57 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com