【发布时间】:2012-01-28 01:22:52
【问题描述】:
我有 2 个元素,2 个尺寸完全相同的图像,一个在另一个之上。假设它们被称为 A 和 B(A 是最上面的)。我所做的是,当您将鼠标悬停在 A 上时,它的 z-index 递减 2,因此 B 现在位于顶部,并且 B 的悬停:将其 z-index 增加 2,因此它现在比 A 的原始值高 1 z-index(因此图像 B 保持在顶部,直到您移除鼠标)。所以基本上...
#A {z-index: 5;}
#B {z-index: 4;}
#A:hover {z-index: 3;}
#B:hover {z-index: 6;}
这在 Firefox 和 Chrome 中完美运行,但 IE 不想听到它,而且我的图像在悬停在它们上面时会一直闪烁。任何帮助表示赞赏。定位是绝对的,如果这很重要的话。
@jklm313
这实际上也适用于我的 IE9。也许我应该发布完整的代码,因为我的一个“图像”实际上是一个社交网络按钮。所以这里是:
HTML:
<div id="myTweetBrown"></div>
<div id="myTweet"><?php include ("myPHP/homepageSoc/tweet.php") ?></div>
CSS:
#myTweetBrown {
position: absolute;
background-image: url('../images/tweetBrown.png');
background-repeat: no-repeat;
background-position: center center;
height: 20px;
width: 54px;
left: 381px;
top: 662px;
z-index: 5;
}
#myTweetBrown:hover {
position: absolute;
z-index: 3;
}
#myTweet {
position: absolute;
height: 20px;
width: 54px;
left: 381px;
top: 662px;
z-index: 4;
}
#myTweet:hover {
position: absolute;
z-index: 6;
}
tweet.php:
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://localhost/Joomla173/index.php?option=com_content&view=article&id=69&Itemid=507" data-count="none">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
演示网站链接:***** -- 向下滚动到推文按钮 这只会持续这么长时间,因为我不希望人们有这样的访问权限<.>
【问题讨论】:
标签: css iframe internet-explorer-9 z-index