翻转时背景颜色变化在 IE、FF 中不起作用

发布于 2024-09-14 06:35:00 字数 634 浏览 3 评论 0原文

这看起来很简单,我很困惑为什么它不起作用...我想在滚动 DIV 时更改它的背景图像。它适用于 mac 上的 chrome 和 FF - 但不适用于 FF、PC 上的 IE

CSS - /media/css/mystandard.css

div.flipper {background-color: #FFFFFF;}
div.flipper:hover {background-color: #F8FBFE;}

HTML

<HTML> <HEAD> <link rel="stylesheet" href="/media/css/mystandard.css"/></HEAD><BODY>        
<div class="flipper" >  
hello stack overflow!               
</div>
</BODY></HTML>

re:Catfish

感谢您的提示。不幸的是,我无法使用标签,因为我计划更改完整 DIV 的背景颜色(有点像 twitter.com 滚动时的推文视图),并且不想将 div 中的所有文本设为链接

this seems very simple and im puzzled as to why its not working...I want to change the background image of a DIV when rolling over it. It works on chrome and FF on a mac - but then not FF, IE on PC

CSS - /media/css/mystandard.css

div.flipper {background-color: #FFFFFF;}
div.flipper:hover {background-color: #F8FBFE;}

HTML

<HTML> <HEAD> <link rel="stylesheet" href="/media/css/mystandard.css"/></HEAD><BODY>        
<div class="flipper" >  
hello stack overflow!               
</div>
</BODY></HTML>

re:Catfish

Thanks for the tip. Unfortunately I can't use the tags because I plan on having the background color of a full DIV change (sort of like twitter.com Tweets view on rollover) and dont want to make all the text in the div a link

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

手心的海 2024-09-21 06:35:00

如果您必须使用

,则需要使用 javascript 来进行悬停。为简单起见,我建议使用 jQuery:

$("div.flipper").hover(
  function() { $(this).addClass("hover"); },
  function() { $(this).removeClass("hover"); }
);

然后将 CSS 更改为:

div.flipper {background-color: #FFFFFF;}
div.hover   {background-color: #F8FBFE;}

If you have to use a <div>, you'll need to use javascript to do the hover. I suggest using jQuery for simplicity:

$("div.flipper").hover(
  function() { $(this).addClass("hover"); },
  function() { $(this).removeClass("hover"); }
);

Then change your CSS to:

div.flipper {background-color: #FFFFFF;}
div.hover   {background-color: #F8FBFE;}
梦魇绽荼蘼 2024-09-21 06:35:00

并非所有浏览器都支持除锚标记 之外的任何内容上的 :hover 伪属性。您必须将 html 更改为

<HTML><BODY> <HEAD> import CSS here </HEAD>     
<div class="flipper" >
<a href="#">  
hello stack overflow!
</a>               
</div>
</BODY></HTML>

,将 css 更改为

div.flipper a{background-color: #FFFFFF;}
div.flipper a:hover {background-color: #F8FBFE;}

Not all browsers support the :hover pseudo attribute on anything except an anchor tag <a>. You'll have to change you're html to

<HTML><BODY> <HEAD> import CSS here </HEAD>     
<div class="flipper" >
<a href="#">  
hello stack overflow!
</a>               
</div>
</BODY></HTML>

and youre css to

div.flipper a{background-color: #FFFFFF;}
div.flipper a:hover {background-color: #F8FBFE;}
浮云落日 2024-09-21 06:35:00

你的问题是你的CSS链接。 您有

在媒体产生问题之前, 第一个切片。
使用此

your problem is with your link for css. You have <link rel="stylesheet" href="/media/css/mystandard.css"/>

the first slice before media creates the problem.
Use this <link rel="stylesheet" href="media/css/mystandard.css"/>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文