IE8,定位和悬停不起作用

发布于 2024-09-17 21:03:33 字数 1079 浏览 14 评论 0原文

我设置了一个伪画廊来显示缩略图并在将鼠标悬停在缩略图上时显示放大的图像。放大的图像相对于其父缩略图定位。

这适用于 Google Chrome 和 Mozilla Firefox,但不适用于 IE8。

我已经做了一些研究,但在这个问题上没有任何进展。在IE8中,同时显示缩略图和放大图像。 “可见性:隐藏”、“悬停”和“绝对位置”似乎在 IE8 中不起作用。

将不胜感激任何帮助。以下是代码片段:

.main{
     float:right;
     display: block;
     Background-color:transparent;
     Margin: 20px 55px 20px 10px;
}

.main img{
     display: block;
     border:0;
}

.main:hover{
     background-color:#ffffff;
     position: relative;
     visibility:visible;
     z-index: 1400;
}

/*for bigger images*/
.main bigger {
     width: 500px;
     height: 500px;
     position: absolute;
     left: -2000px;
     visibility: hidden;
     overflow: hidden;
     background-color:transparent;
     border:0;
}

.main:hover img{
     z-index: 1400;
     position: relative;
}

.main:hover bigger{
     z-index: 1500;
     display:block;
     width: 500px;
     height: 500px;
     top: -100px;
     left: 200px;
     overflow: visible;
     visibility: visible;
     background-color: transparent;
     clear: none;
}

谢谢

I have a pseudo-gallery set up to display thumbnails and display enlarged image when hovered on thumbnails. The enlarged image is positioned relative to its parent thumbnail.

This works in Google chrome and Mozilla Firefox but not in IE8.

I have done some research with no progress on the matter. In IE8, both thumbnail and enlarged image are displayed. Neither 'Visibility: Hidden', 'hover' nor 'absolute position' seem to work in IE8.

Would appreciate any help. the following is a snippet of code:

.main{
     float:right;
     display: block;
     Background-color:transparent;
     Margin: 20px 55px 20px 10px;
}

.main img{
     display: block;
     border:0;
}

.main:hover{
     background-color:#ffffff;
     position: relative;
     visibility:visible;
     z-index: 1400;
}

/*for bigger images*/
.main bigger {
     width: 500px;
     height: 500px;
     position: absolute;
     left: -2000px;
     visibility: hidden;
     overflow: hidden;
     background-color:transparent;
     border:0;
}

.main:hover img{
     z-index: 1400;
     position: relative;
}

.main:hover bigger{
     z-index: 1500;
     display:block;
     width: 500px;
     height: 500px;
     top: -100px;
     left: 200px;
     overflow: visible;
     visibility: visible;
     background-color: transparent;
     clear: none;
}

THANKS

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

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

发布评论

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

评论(2

在巴黎塔顶看东京樱花 2024-09-24 21:03:33
/*for bigger images*/ 
.main bigger { width: 500px; height: 500px; position: absolute; left: -2000px; visibility: hidden; overflow: hidden; background-color:transparent; border:0; }

.main:hover img{ z-index: 1400; position: relative; }

.main:hover bigger{ z-index: 1500; display:block; width: 500px; height: 500px; top: -100px; left: 200px; overflow: visible; visibility: visible; background-color: transparent; clear: none; }

更大应该是一个元素或一个类。如果它是一个类,它应该是 .bigger ,对吗?

/*for bigger images*/ 
.main bigger { width: 500px; height: 500px; position: absolute; left: -2000px; visibility: hidden; overflow: hidden; background-color:transparent; border:0; }

.main:hover img{ z-index: 1400; position: relative; }

.main:hover bigger{ z-index: 1500; display:block; width: 500px; height: 500px; top: -100px; left: 200px; overflow: visible; visibility: visible; background-color: transparent; clear: none; }

is bigger supposed to be an element or a class. if it's a class, it should be .bigger , right?

所有深爱都是秘密 2024-09-24 21:03:33

它看起来像这样:

不要那样做。

元素不存在。即使在 XHTML 中,您也不能只编写自己的元素;您还需要编写自己的元素。无论如何,如果不创建自定义 DTD,这可能仍然无法使其在 IE 中工作,因为 IE 并不真正支持 XHTML。

Chrome 和 Firefox 在处理无法识别的元素方面比 IE8 宽松一些,这就是它在这些浏览器中工作的原因。

我建议您向图像添加一个 bigger 类: 并删除 元素。

it looks like this: <a class="main" href="#"><img src="" /><bigger><img src="" /></bigger></a>

Don't do that.

The <bigger> element doesn't exist. You can't just make up your own elements, even in XHTML; not without creating a custom DTD anyway, which probably still wouldn't make it work in IE, since IE doesn't really support XHTML.

Chrome and Firefox are a bit more lenient in how they deal with unrecognized elements than IE8, which is why it works in those.

I would suggest you add a bigger class to the image instead: <img src="" class="bigger" /> and get rid of the <bigger> element.

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