【问题标题】:How to show/hide new <div> near <div> by mouseover/mouseout?如何通过 mouseover/mouseout 在 <div> 附近显示/隐藏新的 <div>?
【发布时间】:2013-08-15 11:25:33
【问题描述】:

我有一个容器(主容器),当鼠标悬停在它上面时 - 在主容器附近显示新容器(添加容器)。将鼠标悬停在此容器(主容器和添加容器)上时,添加容器会停留在屏幕上。当鼠标移出主容器或添加容器时 - 添加容器隐藏。问题:在Opera添加容器中不停留在屏幕上。

HTML:

<div style='float:left; width:100px;' class='triggerShowHidePanel' panelID='1'>    
--- main content ---    
<div class='categoryContainer1' style='float:left; display:none; width:100px;'>
--- addition content ---    
</div>
</div>

JS:

$('.triggerShowHidePanel').bind('mouseover', function() {
    var positionX = $(this).position().top;
    var positionY = $(this).position().left + 100;
    $('.categoryContainer' + $(this).attr('panelID')).show();
    $('.categoryContainer' + $(this).attr('panelID')).offset({ 
        top: Math.round(positionX), 
        left: Math.round(positionY)
    });     
}).bind('mouseout', function() {
    $('.categoryContainer' + $(this).attr('panelID')).hide();
    $('.categoryContainer' + $(this).attr('panelID')).offset({ top: 0, left: 0 });
});

【问题讨论】:

  • 你想要这种类型吗? jsfiddle.net/gUap5/1
  • "--- 附加内容 ---" 必须在屏幕上,而将鼠标悬停在主要内容或附加内容上。

标签: javascript jquery css opera


【解决方案1】:

http://jsfiddle.net/gUap5/5/

我添加了一个容器 div 来将 mouseover 和 mouseout 事件绑定到这两个元素。

【讨论】:

  • 它仍然无法在歌剧中工作/当我尝试另外块显示链接和角色鼠标悬停在它上面块隐藏jsfiddle.net/gUap5/7
  • 嗯,它在我这边工作(Mac 上的 Opera 15)。他们最近切换到 webkit,也许你有一个带有他们自己引擎的旧版本。你用的是哪个版本?
  • Opera/9.80 (Windows NT 5.1) Presto/2.12.388 版本/12.16
猜你喜欢
  • 2018-08-15
  • 1970-01-01
  • 2011-03-08
  • 2020-08-23
  • 1970-01-01
  • 2014-06-15
  • 1970-01-01
  • 2014-10-28
  • 2015-03-25
相关资源
最近更新 更多