gpt4 book ai didi

html - Internet Explorer 中的绝对定位和滚动条

转载 作者:可可西里 更新时间:2023-11-01 13:17:51 24 4
gpt4 key购买 nike

免责声明

这个问题是转帖。我本来问的here .虽然有一个好心人帮助我,但他最终找不到理想的解决方案。现实情况是 Doctype 没有像 Stack Overflow 那样拥有大量用户。这对我来说是一个重要的问题,我真的需要更多的意见。

问题

我已经使用 HTML 和 CSS 实现了 TreeView 。当悬停此 TreeView 中的元素时,工具提示会出现在其下方。在 Firefox 中一切正常,但在 Chrome 或 Firefox 中却不行。

我的问题是工具提示使用绝对定位以允许其内容显示在其他元素之上。当我在 Firefox 中滚动时,这些工具提示的位置会移动以反射(reflect)它们的新位置。但是,Internet Explorer 保留元素的原始位置。因此,如果我将鼠标悬停在滚动的元素上,工具提示将显示在该元素最初所在的位置下方。

我读过可以通过添加 position: relative 到我的 TreeView 来解决这个问题,但这会阻止工具提示悬停在整个页面上。

下面是一些示例代码来说明我的问题:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>

<!-- import css files -->
<link href="example.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="tree-view">
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
</div>
<div id="main-content">
main
</div>
</div>
</body>
</html>

这是示例的 CSS:

#wrapper
{
}

#tree-view
{
float: left;
width: 200px;
height: 400px;
background-color: #BBFFFF;
overflow: auto;
}

#main-content
{
float: left;
width: 600px;
height: 400px;
background-color: #FFFFBB;
}

#tree-view a
{
display: block;
position: relative;
}

#tree-view a span.tooltip
{
position: absolute;
z-index: 100;
display: none;
}

#tree-view a:hover span.tooltip
{
/* positioning */
margin-left: 1em;
margin-top: 1em;
display: block;
position: absolute;

/*formatting*/
text-decoration: none;
background: #DDD;
border: 1px solid #BBB;
padding: 5px;
white-space: normal;
width: 300px;
color: black;
}

#tree-view .tooltip strong
{
display: block;
}

#tree-view .tooltip .tooltip-info
{
display: block;
}

如果 position: relative 标记从工具提示 anchor 中移除,工具提示将在 Firefox 中正确显示。但是,如果没有它,工具提示将无法在 Internet Explorer 中正确显示。

感谢您的帮助。

最佳答案

不久前我停止使用自己的工具提示并切换到 Qtip ( http://craigsworks.com/projects/qtip/ )。它经过跨浏览器测试,易于实例化,而且看起来很出色。如果您碰巧是 ThemeRoller 用户,测试版(在夜间构建中可用)完全支持 ThemeRoller 样式。总的来说,我强烈建议考虑使用它来让生活更轻松......它只是减少了大脑损伤。

在即将发布的 JQuery UI 版本中,核心中将内置一个类似的功能。类似的脚本可用于 Dojo、Prototype 和 MooTools。

关于html - Internet Explorer 中的绝对定位和滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3459497/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com