IMG 标签的 CSS 内容属性

标签 css

img:after {
   content:attr(title);
}

这不起作用,可能是因为 img 标签是空的,没有结束标签。有什么解决方法可以在没有 js 的情况下解决这个问题吗?

最佳答案

img 是一个替换元素w3c CSS 2.1 spec说:

Note. This specification does not fully define the interaction of :before and :after with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification.

我不知道发生了什么“ future 规范”。它在 Chrome 中不起作用,这是肯定的:)。

关于IMG 标签的 CSS 内容属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6009176/

相关文章:

html - IE 框阴影显示 1px 边框效果

css - 字体在 Windows 中看起来失真

jquery - addClass 在窗口滚动时闪烁

html - 行高和背景颜色(Span 与 Div)

javascript - Bootstrap 4 order sm(手机)

html - 如何垂直对齐 @Html.TextAreaFor 中的文本

html - Materialise <div 类 ="col s12 m6 l3"> 不工作

css - IE选择可见,尽管它的父级是隐藏的

html - 工具提示容器显示地下元素

python - 使用 beautifulsoup 在 python 中使用 colspan 解析表