1

我用 css sprites 制作了一个 css 菜单,但问题在于 sprite 我们不使用仅在后台使用的内联图像,因此如果在浏览器中禁用图像,则不会显示任何内容。有什么解决方案吗?

例如 :

查看此菜单并关闭图像: http: //line25.com/wp-content/uploads/2009/css-menu/demo/demo.html(如果在浏览器中禁用图像,则不会看到)

这个菜单反对这个报价

确保您的网站在禁用图像的情况下工作

Creating a site that relies too heavily on images is never a good

主意。尽管几乎已成为过去,但仍有用户以非常低的互联网速度运行。此外,如果用户需要(无论出于何种原因)禁用图像,他们仍然可以访问他们需要的所有内容吗?

http://csswizardry.com/quick-tips/#tip-02

我们不应该使用这种类型的导航吗?

4

3 回答 3

7

不要将精灵用于内容图像。它们依赖于表示层 (CSS) 中的背景图像。将您的内容放在内容层(HTML)中。

于 2009-10-01T14:27:55.850 回答
2

您可以创建一个 1x1 透明像素图像并将其放在具有精灵的 div 中。例如:

<style type="text/css">
#linkContainer {background:url(images/sprite.gif) 0 50 no-repeat}
//sprite selection width/height, set cursor to pointer so users know its a link
#linkContainer img {width:50px;height:25px;cursor:pointer}  
<style>
<div id="buttonContainer"><img src="pixel.gif" alt="Your alt text"></div>
于 2009-10-18T22:06:21.843 回答
-1

为什么需要在菜单中添加替代文本?

于 2009-10-01T14:27:09.470 回答