简体   繁体   English

将鼠标悬停在SVG路径上时如何显示div?

[英]How can I make a div appear when hovering over a SVG path?

I'm working on this SVG image , jsfiddle 我正在处理此SVG图像jsfiddle

 <div id='one'>
  items that should appear when hovering over 01(red circle) on the svg image
</div>

<div id='two'>
  items that should appear when hovering over 02(green circle) on the svg image
</div>
<div id='three'>
  items that should appear when hovering over 03(purple circle) on the svg image
</div>

I need the div appear when hovering over the relevant SVG circle , and the circle should be highlighted when hovering over it, 我需要将div悬停在相关的SVG圆上时出现,并且将圆悬停在相应的SVG圆上时应突出显示该圆,

I'm new to JS and don't know where to start , I looked for libraries like SVG.js and vivus.js but they are too complicated for this small task , please help me out , thanks 我是JS的新手,不知道从哪里开始,我在寻找SVG.js和vivus.js之类的库,但是它们对于这个小任务来说太复杂了,请帮帮我,谢谢

Using jQuery, show/hide a div when the mouse enters and leaves the desired circle respectively. 使用jQuery,当鼠标分别进入和离开所需的圆圈时,显示/隐藏div。

Below is the snippet for div toggle and see the working fiddle 以下是div切换的代码段,请参阅工作提琴

JS JS

$(function() {
  $("#XMLID_359_").hover(function(){
    $('#one').toggle();
    $(this).addClass('transform');
  });

  $("#XMLID_362_").hover(function(){
    $('#two').toggle();
    $(this).addClass('transform');
  });

  $("#XMLID_67_").hover(function(){
    $('#three').toggle();
    $(this).addClass('transform');
  });

  $("#XMLID_359_,#XMLID_362_, #XMLID_67_").mouseleave(function(){
    $(this).removeClass('transform');
  });
});

CSS CSS

#one, #two, #three{
  display: none;
}
#XMLID_359_, #XMLID_362_, #XMLID_67_{
  transition: all 200ms ease-in;
}
.transform{
  transform: scale(1.1, 1.1);
}
#XMLID_362_.transform{
  transform: scale(1.1, 1.1) translateX(-72.3px);
}

You would have to include the jQuery library in the application. 您将不得不在应用程序中包括jQuery库。

Try following code 尝试以下代码

 function showMe1(){ document.getElementById('one').style.color=""; } function showMe2(){ document.getElementById('two').style.color=""; } function showMe3(){ document.getElementById('three').style.color=""; } document.getElementById('one').style.color="transparent"; document.getElementById('two').style.color="transparent"; document.getElementById('three').style.color="transparent"; 
  div:hover { visibility: visible; } 
  <div id='one' onmouseover="showMe1()"> items that should appear when hovering over 01(red circle) on the svg image </div> <div id='two' onmouseover="showMe2()"> items that should appear when hovering over 02(green circle) on the svg image </div> <div id='three' onmouseover="showMe3()"> items that should appear when hovering over 03(purple circle) on the svg image </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 悬停在一个div上时如何显示更多div? - How to make more divs appear when hovering over one div? 将鼠标悬停在其父div上时,如何更改链接为对象的SVG的属性? - How do I change properties of an SVG linked as object when hovering over its parent div? 当用户将鼠标悬停在 div 上但停止时关闭时,如何使我的下拉菜单保持打开状态? - How can I make my dropdown menu remain open when user is hovering over the div but close when they stop? jQuery:将鼠标悬停在另一个div上时,如何控制div的不透明度? - jQuery: how can I control a div's opacity when hovering over another div? 将鼠标悬停在元素上但不出现在鼠标指针上时如何显示div? - How to have a div show up when hovering over elements but not appear over the mouse pointer? 我可以在Div内显示内容吗? 什么时候将单独的Div悬停在光标上? - Can I Make Content Appear Within a Div; When a Separate Div is Hovered Over With The Cursor? 悬停在另一个元素上时,使一个元素出现并进行调整 - Make an element appear and make adjustments when hovering over another element 如何使svg圆始终显示在图形线路径上方? - How can I make an svg circle always appear above my graph line path? 将鼠标悬停在 tex 上并按下鼠标按钮时,如何使文本不可见? - How can I make the text invisible when hovering over a tex and pressing the mouse button? 将鼠标悬停在图像上时,如何更改两个或多个图像? - when hovering over an image, how can I make two or more images change?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM