css - 更改导航栏图像的 CSS 以适应 IE

标签 css internet-explorer

我的水平导航栏填充了来自包含所有子图像的一个图像的链接图像;每个导航项图像都由较大图像中的像素位置标识。这在 Firefox 和 Safari 中工作得很好,但在 IE 中,所有图像在导航栏中都错放得太低(只能勉强看到文字的顶部)。两个问题:

  • 如何在 css 中修复此问题,使其与 IE 的更新版本(和当前版本)向后兼容
  • 我需要单独的 IE 样式表吗?

这是 css(仅针对一些链接进行了截断):

ul#navbar {
    width: 750px;
    height: 22px;
    margin: 0px;
    padding: 0px;
    text-indent: -9999px;
    border: none;
}
ul#navbar li {
    float: left;
    height: 22px;
    margin: 0px;
    padding: 0px;
    list-style-type: none;
    border: none;
    /*position:absolute;*/
}
ul#navbar li a {
    display: block;
    height: 22px;
    border: none;
}

.home {
    left: 0px;
    width: 78px;
    background-image: url(../images/nav/new_nav.jpg);
    background-repeat: no-repeat;
    background-position: 0px 0px;
}

.classes {

    /*left: 78px; */
    width: 92px;
    background-image: url(../images/nav/new_nav.jpg);
    background-repeat: no-repeat;
    background-position: -100px 0px; 
}

.训练{ 左:170px; 宽度:89px; 背景图像:url(../images/nav/new_nav.jpg); 背景重复:不重复; 背景位置:-200px 0px;

最佳答案

我为 IE 6 使用 *.html

/** 对于 IE6 / *html #related-products { 宽度:300px; 溢出:可见;
} *html #related-products ul { 职位:相对; 左:-65px;
} *html #related-products li { 边框:无;
} /
IE6 hack 结束 **/

否则会有 IE 条件注释。

http://www.quirksmode.org/css/condcom.html

至于单独的样式表,你可以创建一个让你的服务器端语言检测浏览器,如果 Internet Explorer 确保你的 IE 被添加,否则你可以将它们添加到现有的 CSS 文件中。这两个我都做过。

关于css - 更改导航栏图像的 CSS 以适应 IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2478990/

相关文章:

css - 删除 XUL menuitem 中的图像/图标空间和 menupopup 中的垂直线

javascript - 自动关闭切换菜单的ul

javascript - 为什么我的 dc-js 轴显示得这么粗,而刷子过滤器显示为不透明的黑色?

c# - 多个图像处理程序调用导致 IE 在弹出窗口中挂起

javascript - 创建自定义 css 或 js 文件服务器端

css - dropzone 图标显示在 dropzone 之外

html - Windows Phone 8 的 IE10 中的奇怪文本大小

javascript - IE JS 类型错误 : Object does not support this property or method

css - 矩阵过滤器在 IE7 上对空白敏感吗?

html - Internet Explorer 8 忽略表格上的列组宽度