css - 具有 "position: absolute;"的 <span> 元素是否表现为 block 级元素?

标签 css block html absolute

<span>带有 position: absolute; 的元素无需将其更改为 display: block; 即可拥有高度、宽度、填充等或 inline-block;

它似乎可以工作,但是所有浏览器都可以省略 display: block/inline-block 吗?对于 <span>带有 position: absolute; 的元素?

最佳答案

规范 says yes :

Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned, the computed value of 'float' is 'none', and display is set according to the table below. The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and the box's containing block.

该表表示任何内联显示值(inline, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table -row, table-cell, table-caption, inline-block) 成为 block

关于css - 具有 "position: absolute;"的 <span> 元素是否表现为 block 级元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17737194/

相关文章:

CSS - 规则适用于@media(最大宽度 : 550px) but not @media (max-width: 750px)

html - 如何更改图像的位置而不影响其左侧的文本?

javascript - 在固定高度的 y 轴上溢出滚动

css - 将一个div居中对齐,然后向左移动

css - HTML DIV 按钮定位

linux - 在没有 fflush(stdout) 的情况下将 block 缓冲数据写入文件

ios - Obj-C ARC模式下的dealloc方法是否需要手动释放block变量?

ruby - block 第一次不识别变量

jquery - 在视频标签中隐藏放大控件 - Edge 和 IE

html - SEC7113 : CSS was ignored due to mime type mismatch