html - 为什么图像使用显示: inline but behaves like an inline-block element

标签 html image default css

为什么图片的默认显示样式是inline而不是inline-block?

img 元素的 inline 和 inline-block 之间是否有任何区别,据我所知,它们的行为方式完全相同。

最佳答案

IMG 是一个Inline & Replaced 元素。

A replaced element is any element whose appearance and dimensions are defined by an external resource.

根据 W3C

The IMG element has no content; it is usually replaced inline by the image designated by the src attribute, the exception being for left or right-aligned images that are "floated" out of line.

查看此链接了解更多 http://reference.sitepoint.com/css/replacedelements

关于html - 为什么图像使用显示: inline but behaves like an inline-block element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9928211/

相关文章:

erlang - 使用默认值初始化记录

c# - 运行时类型的默认值

c# - C# 中 default(IInterface) 的用途

java - 如何在Java中使用固定大小的 block 扫描图像?

javascript - 使用 React Native Webview 添加本地 HTML 和 JS 文件

php - Wordpress:编辑子主题

javascript - 如何从文本区域获取换行符

ios - 使用相机 session 捕获的裁剪图像

c - 在 C 中读取二进制文件期间检测到堆栈粉碎

javascript - 在 Javascript/JQuery 中,如何读取 JSON 文件?