热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在IE6中,CSSsprite基于滚动的闪烁。-CSSspritebasedrolloverblinksinIE6

ImusingtheCSSbasedrollovertrickthatswitchesthebackgroundpositionoftheelementsback

I'm using the CSS based rollover "trick" that switches the background position of the element's background image on hover.

我使用基于CSS的翻转“技巧”来切换元素背景图像的背景位置。

The CSS

CSS

#welcome #step1 
{background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll left top;}
#welcome #step1:hover 
{background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll right top;}

The HTML

HTML

...

Naturally IE6 messes this simple thing up. All my rollovers blink.

当然,IE6把这个简单的东西搞砸了。我所有的滚动闪烁。

Upon mouse over the image vanishes for a moment then moves to the over state. An interesting quirk, if I navigate away from the page then press the BACK button the problem seems to go away!

鼠标在图像上消失片刻,然后移动到超状态。一个有趣的怪癖是,如果我离开页面,然后按下后退按钮,问题似乎就消失了!

I'm thinking it has to do with the PNG image files (though they don't have any transparency) Or perhaps something simple as doc type (XHTML transitional)

我认为它与PNG图像文件有关(尽管它们没有任何透明性),或者可能是简单的doc类型(XHTML过渡)

Thanks for your insight.

谢谢你的见解。

EDIT (SOLVED):

编辑(解决):

Jitendra provided the link to solve the problem. I simply added this to the head:

Jitendra提供了解决该问题的链接。我只是把这个加到头部:


6 个解决方案

#1


3  

See these solutions-

看到这些解决方案,

http://ajaxian.com/archives/no-more-ie6-background-flicker

http://ajaxian.com/archives/no-more-ie6-background-flicker

http://www.hedgerwow.com/360/bugs/dom-fix-ie6-background-image-flicker.html

http://www.hedgerwow.com/360/bugs/dom-fix-ie6-background-image-flicker.html

#2


3  

The browser is requesting the image from the server for each CSS rule where you specify the url() property. To fix this, simply combine the background portion of your two rules into one rule and set the background-position property for each state of the css sprite.

浏览器正在为您指定url()属性的每个CSS规则从服务器请求映像。要解决这个问题,只需将两个规则的背景部分合并到一个规则中,并为css精灵的每个状态设置背景位置属性。

#step1, #step1:hover {
    background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll;
}
#step1 {
    background-position: left top;
}
#step1:hover {
    background-position: right top;
}

This problem actually happens in many browsers. It's just more noticeable in IE6.

这个问题实际上在许多浏览器中都存在。这在IE6中更加明显。

As a side note, if you're using IDs, specifying two ids in your selector is unnecessary. IDs should be unique to the page.

作为补充说明,如果您正在使用IDs,则无需在选择器中指定两个id。id对页面应该是唯一的。

#3


1  

I don't have IE6 around anymore to test with, but have you checked to make sure that the image is fully cacheable by the client? It should have an explicit Expires or Cache-Control: max-age HTTP header.

我已经没有IE6可以测试了,但是你检查过图片是否可以被客户缓存吗?它应该有一个显式的过期或Cache-Control: max-age HTTP头。

#4


1  

This article has a discussion of the triggers of this problem and some other solutions: http://web.archive.org/web/20100105213004/http://www.fivesevensix.com/studies/ie6flicker/

本文讨论了这个问题的触发因素以及其他一些解决方案:http://web.archive.org/web/20100105213004/http://www.fivesevensix.com/studies/ie6flicker/

Also, the CSS to fix this as provided by Gabriel can be improved to:

另外,Gabriel提供的CSS修复可以改进为:

#step1 {
    background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll left top;
}
#step1:hover {
    background-position: right top;
}

#5


0  

for fun, what happens if your :hover style specifies only

有趣的是,如果您的:hover样式只指定

 {background-position: right top;}

#6


0  

Sounds like a typical case of 'IE6 Flicker' which is caused by a setting in IE6. The browser re-requests the image from the server on hover... Stupid right? Have you tried 'Double Buffering' the image? By this I mean place the same background image on both the parent element and the link itself. Example below:

这听起来像是IE6中设置的“IE6闪烁”的典型例子。浏览器在悬浮状态下重新请求服务器的图像……愚蠢的对吧?你尝试过“双缓冲”图像吗?我的意思是在父元素和链接本身上放置相同的背景图像。在下面的例子:

#welcome {
background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll left top;
}
#welcome #step1 {
background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll left top;
}
#welcome #step1:hover {
background: transparent url(../img/mock/homepage_welcome_step1.png) no-repeat scroll right top;
}

Let me know how you get on :)

告诉我你的进展情况:


推荐阅读
  • 本文介绍了前端人员必须知道的三个问题,即前端都做哪些事、前端都需要哪些技术,以及前端的发展阶段。初级阶段包括HTML、CSS、JavaScript和jQuery的基础知识。进阶阶段涵盖了面向对象编程、响应式设计、Ajax、HTML5等新兴技术。高级阶段包括架构基础、模块化开发、预编译和前沿规范等内容。此外,还介绍了一些后端服务,如Node.js。 ... [详细]
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
  • express工程中的json调用方法
    本文介绍了在express工程中如何调用json数据,包括建立app.js文件、创建数据接口以及获取全部数据和typeid为1的数据的方法。 ... [详细]
  • 本文介绍了DataTables插件的官方网站以及其基本特点和使用方法,包括分页处理、数据过滤、数据排序、数据类型检测、列宽度自动适应、CSS定制样式、隐藏列等功能。同时还介绍了其易用性、可扩展性和灵活性,以及国际化和动态创建表格的功能。此外,还提供了参数初始化和延迟加载的示例代码。 ... [详细]
  • 第8章 使用外部和内部链接
    8.1使用web地址LearnAboutafricanelephants. ... [详细]
  • Vue基础一、什么是Vue1.1概念Vue(读音vjuː,类似于view)是一套用于构建用户界面的渐进式JavaScript框架,与其它大型框架不 ... [详细]
  • ①页面初始化----------收到客户端的请求,产生相应页面的Page对象,通过Page_Init事件进行page对象及其控件的初始化.②加载视图状态-------ViewSta ... [详细]
  • 前言:关于跨域CORS1.没有跨域时,ajax默认是带cookie的2.跨域时,两种解决方案:1)服务器端在filter中配置详情:http:blog.csdn.netwzl002 ... [详细]
  • 表单代码 ... [详细]
  • 本文讨论了如何在codeigniter中识别来自angularjs的请求,并提供了两种方法的代码示例。作者尝试了$this->input->is_ajax_request()和自定义函数is_ajax(),但都没有成功。最后,作者展示了一个ajax请求的示例代码。 ... [详细]
  • 从零基础到精通的前台学习路线
    随着互联网的发展,前台开发工程师成为市场上非常抢手的人才。本文介绍了从零基础到精通前台开发的学习路线,包括学习HTML、CSS、JavaScript等基础知识和常用工具的使用。通过循序渐进的学习,可以掌握前台开发的基本技能,并有能力找到一份月薪8000以上的工作。 ... [详细]
  • 本文介绍了Java后台Jsonp处理方法及其应用场景。首先解释了Jsonp是一个非官方的协议,它允许在服务器端通过Script tags返回至客户端,并通过javascript callback的形式实现跨域访问。然后介绍了JSON系统开发方法,它是一种面向数据结构的分析和设计方法,以活动为中心,将一连串的活动顺序组合成一个完整的工作进程。接着给出了一个客户端示例代码,使用了jQuery的ajax方法请求一个Jsonp数据。 ... [详细]
  • Java图形化计算器设计与实现
    本文介绍了使用Java编程语言设计和实现图形化计算器的方法。通过使用swing包和awt包中的组件,作者创建了一个具有按钮监听器和自定义界面尺寸和布局的计算器。文章还分享了在图形化界面设计中的一些心得体会。 ... [详细]
  • 我用Tkinter制作了一个图形用户界面,有两个主按钮:“开始”和“停止”。请您就如何使用“停止”按钮终止“开始”按钮为以下代码调用的已运行功能提供建议 ... [详细]
  • 工作经验谈之-让百度地图API调用数据库内容 及详解
    这段时间,所在项目中要用到的一个模块,就是让数据库中的内容在百度地图上展现出来,如经纬度。主要实现以下几点功能:1.读取数据库中的经纬度值在百度上标注出来。2.点击标注弹出对应信息。3 ... [详细]
author-avatar
林友骏091
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有