本文介绍了用于打印替代文本的CSS属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨 我有一个标题为gif的标题: < h1>< img src =" mytitle。 GIF" alt ="这是我的标题">< / h1> 所以这是基于文本的浏览器和搜索引擎友好且可以轻松 用样式表格式化。 现在我有一个单独的media =" print"样式表。由于标题gif确实 在打印时看起来不太好,因此有一个CSS属性 输出alt属性中的文本会非常好。 display:none使图像在没有替换的情况下消失。我可以 复制h1标签并给出两个实例类名,可以在相应的样式表中定义 as display:none,但这会让人感到困惑 各类非CSS浏览器。我会喜欢这样的东西:alttext。 有没有办法做到这一点? 感谢您的每一个提示。 Markus Hi I have a title with a title gif: <h1><img src="mytitle.gif" alt="This is my title"></h1> So this is text-based browser and search-engine friendly and can be easilyformatted with a style sheet. Now I have a separate stylesheet for media="print". As the title gif doesnot look very good when printed it would be very nice to have a CSS propertythat outputs the text in the alt attribute. display:none makes the image disappear without a replacement. I couldduplicate the h1 tag and give both instances class names that can be definedas display:none in the appropriate style sheet, but that would confusenon-CSS browsers of all kinds. I would love something like display:alttext. Is there a way to do that? Thanks for every hint. Markus推荐答案 img:after {display:block; content:attr(alt)} 不能在IE中工作。 - Spartanicus img:after{display:block;content:attr(alt)} Won''t work in IE. --Spartanicus 不,不是。 < H1>搜索引擎是空的。 No, it isn''t. <h1> is empty for search engines. 凌乱,但确实有效。 < h1 class =" noscreen">这是我的头衔< / h1> < h1 class =" noprint">< img src =" mytitle.gif" alt ="这是我的标题">< / h1> 而且样式显然是屏幕css中的noscreen {display:none;}和 noprint {display:none;}在print css中。 Messy, but it works. <h1 class="noscreen">This is my title</h1><h1 class="noprint"><img src="mytitle.gif" alt="This is my title"></h1> And the style is obviously noscreen {display:none;} in the screen css andnoprint {display:none;} in the print css. 这篇关于用于打印替代文本的CSS属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 06:43