自动标题:img:after {content:attr(alt)} [英] Automatic captions: img:after { content:attr(alt) }

查看:233
本文介绍了自动标题:img:after {content:attr(alt)}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,这个CSS声明在我的页面上没有做任何事情。

我已经在其他地方大量使用这种技术,并且它有效。

这也是alt值的问题。这没有任何结果:


img:在{

内容:"测试" ;;

}


虽然这显示测试在所有div元素之后:


div:在{

内容:"测试" ;;

}


我已经摆弄了设置可见性,显示和其他

属性,但由于某些原因,img元素似乎不支持

内容他们:之前和之后:伪元素。


因为这实际上是W3提到的一个提示( http://www.w3.org/TR/

WCAG10-CSS-TECHS / #Alt),几乎在那里显示这是'b
对我来说有点混乱。有没有让这个工作的经验?

This CSS declaration doesn''t do anything on my page, for some reason.
I''ve made heavy use of this technique in other places, and it works.
It''s not a problem with the alt value, either. This shows nothing:

img:after {
content:"Test";
}

While this shows "Test" after all div elements:

div:after {
content:"Test";
}

I''ve fiddled around with setting visibility, display and other
properties, but for some reason img elements seem not to support
content in their :before and :after pseudo-elements.

Since this is in fact a tip mentioned by W3 (http://www.w3.org/TR/
WCAG10-CSS-TECHS/#Alt ), and shown there almost verbatim, that''s
somewhat confusing to me. Any experience with getting this to work?

推荐答案

链接破了。这是我的意思:

http://www.w3.org/TR/WCAG10-CSS-TECHS/#Alt

Link broke. This is the one I meant:

http://www.w3.org/TR/WCAG10-CSS-TECHS/#Alt


Scripsit Christoph:
Scripsit Christoph:

由于某种原因,img元素似乎不支持

内容:before和:after伪元素。
for some reason img elements seem not to support
content in their :before and :after pseudo-elements.



这太奇怪了。我只在Firefox 2上测试过它,但似乎

也不支持输入元素。也许那是'因为它们是

取代了标记术语中空元素的元素。


-

Jukka K .Korpela(Yucca)
http:// www。 cs.tut.fi/~jkorpela/

That''s strange enough. I''ve only tested it on Firefox 2, but it seems to
fail to support it for input elements, too. Maybe that''s because they are
replaced elements that are empty elements in markup terms.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


6月22日晚上10点08分,Jukka K. Korpela < jkorp ... @ cs.tut.fiwrote:
On Jun 22, 10:08 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:

Scripsit Christoph:
Scripsit Christoph:

for some原因img元素似乎不支持

内容:before和:after伪元素。
for some reason img elements seem not to support
content in their :before and :after pseudo-elements.



这太奇怪了。我只在Firefox 2上测试过它,但似乎

也不支持输入元素。也许那是'因为它们是

取代了标记术语中空元素的元素。


-

Jukka K .Korpela(Yucca) http://www.cs.tut。 fi / ~jkorpela /



我试过测试< img>< / imginstead of< img />,但当然是
对于有效的XHTML,
元素必须为空,因此无法正常工作。我会尝试使用Opera和Firefox 3.0alpha来实现它的价值 - 如果W3C推荐它,我会更好地认为它可能只是一个问题浏览器没有

正确实施标准。


如果这不起作用,我想是时候了< div class = 数字>。

不幸的是,我可能不得不再次填写标题文本,

除非有某种方法可以访问第一个孩子类型img'的alt

属性"来自div选择器。到目前为止,我只看到attr()

用于元素自身的属性。


-

cb

I''ve tried testing <img></imginstead of <img />, but of course the
element has to be empty for valid XHTML, so that didn''t work. I''ll try
it with Opera and Firefox 3.0alpha - if the W3C recommends it, I''m
more apt to think it might just be a problem of the browsers not
implementing the standard properly yet.

If that doesn''t work, I guess it''s time for <div class="figure">.
Unfortunately, I''ll probably have to fill in the caption text again,
unless there is some way to access "first child of type img''s alt
attribute" from within a div selector. So far, I''ve only seen attr()
used for the element''s own attributes.

--
cb


这篇关于自动标题:img:after {content:attr(alt)}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆