我对大多数网络开发内容都很陌生,所以我恳请您提供一些支持。我有一个图像地图,其中我分配了几个区域,在单独的 div 中触发不同的内容。我现在想为 onmouseover 触发器添加延迟,以便仅当用户将光标放置在该区域上而不是意外地将鼠标悬停在该区域上时,div 中的内容才会更新。
这是我用来切换 div 内容的 js:
function showHideDivs(indx){
hideDivs();
oShowHideDivs[indx].style.display = 'block';
}
function hideDivs(){
for(i=0; i < oShowHideDivs.length; i++){
oShowHideDivs[i].style.display = 'none';
}
}
window.onload=function(){
oShowHideDivs = document.getElementById('container').getElementsByTagName('div');
var oMap = document.getElementById('myMap');
for(i=0; i < oMap.areas.length; i++){
oMap.areas[i].indx = i;
oMap.areas[i].onmouseover=function(){
showHideDivs(this.indx);
}
}
}
Run Code Online (Sandbox Code Playgroud)
那么我如何实现延迟以及在哪里实现?提前谢谢!一月
编辑:我现在使用这种方法:
oMap.areas[i].onmouseover=function(){
var area=this;
var delay=setTimeout(function(){showHideDivs(area.indx);},100);
area.onmouseout=function(){clearTimeout(delay);};
}
Run Code Online (Sandbox Code Playgroud)
对我来说似乎是最简单的。谢谢提示!
我有几个 SVG 路径元素,每个元素都位于父 svg 元素内,如下所示:
<svg class="connector" style="position:absolute;left:277.5px;top:65px" position="absolute" pointer-events:"none" version="1.1" xmlns="http://www.w3.org/1999/xhtml" height="152.5px" width="410.015625px">
<path fill="none" stroke="#ff0000" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 310.015625 149.5 410.015625 149.5" id="path1"></path>
</svg>
<svg style="position:absolute;left:277.5px;top:109px" position="absolute" pointer-events:"none" version="1.1" xmlns="http://www.w3.org/1999/xhtml" height="108.5px" width="410.015625px">
<path fill="none" stroke="#880000" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 310.015625 105.5 410.015625 105.5" id="path2"></path>
</svg>
Run Code Online (Sandbox Code Playgroud)
svg 元素(及其子路径)在视觉上是重叠的。
我想要有悬停效果,所以我在每个路径上设置了 mouseenter 和 mouseleave 事件。
当鼠标位于不重叠的区域上方时,悬停会按预期工作,但是,当鼠标位于 svg 元素的边界矩形重叠的区域上方时,鼠标事件不会正确触发。
但是,如果我将相同的两个路径元素放入单个 svg 中,如下所示,则鼠标悬停将按预期工作,即使边界矩形重叠也是如此。
<svg class="connector" style="position:absolute;left:277.5px;top:265px" position="absolute" pointer-events:"none" version="1.1" xmlns="http://www.w3.org/1999/xhtml" height="152.5px" width="410.015625px">
<path fill="none" stroke="#00ff00" stroke-width="6" pointer-events="visibleStroke" d="M0 3C100 3 …Run Code Online (Sandbox Code Playgroud) 我的按钮链接只是 html 中的链接,带有 css 中的背景图像。在 CSS 中,我还有图像的尺寸,以便显示整个图像。
我希望每当鼠标悬停在图像上时图像缩小到 95%。我有 a:hover css,但将尺寸更改为 95% 却不起作用。
是否有捷径可寻?
您可以在http://granthoneymoon.com/temp.html上查看示例页面,导航按钮位于标题内的顶部。
这是我的 CSS
.header_under{
display: none;
width: 300px;
height: 150px;
float: left;
background: red
}
.show:hover ~ .header_under{
display: block;
}
Run Code Online (Sandbox Code Playgroud)
所以我想要的是“header_under”在悬停时出现在网站上。但似乎不起作用
HTML:
<li class="show"><a href='#'><span>Games4u</span></a></li>
Run Code Online (Sandbox Code Playgroud)
和
<div class="bildspel">
<div id="header_under"></div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在学习CSS,我想在将鼠标悬停在某些文本上时,文本消失并且图像上淡入。我已经测试了一些东西,但它没有按照我想要的方式工作。
文本是 a 中的链接,在悬停时我设置了背景图像。我可以在 the 中使用 an,但我希望文本位于 the 的中间,并且它已经位于具有绝对位置的 a 中。
这是 HTML :
<div class="header">
<!--<ul>-->
<div class="header_element">
<a title="Home" href="page.php"> Home </a>
</div>
Run Code Online (Sandbox Code Playgroud)
还有CSS:
div.header_element {
display: table-cell;
text-align: center;
vertical-align: middle;
height: 100%;
}
div.header_element:hover {
background-position: center;
background-image: url("hover.png");
background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
如果有人能帮助我,我将不胜感激。
HTML:
<fieldset>
<legend> XXX </legend>
<label for="photo"> Photo </label>
<input type="file" name="photo" id="photo">
<br>
<label for="imagePreview"> Preview: </label>
<img id="preview">
</fieldset>
CSS:
// 1. In this order, only input:hover works.
label:hover { font-size: 25px;}
input:hover { font-size: 20px;}
// 2. In this order, only label:hover works.
input:hover { font-size: 20px;}
label:hover { font-size: 25px;}
Run Code Online (Sandbox Code Playgroud)
我被要求做这两件事都应该调整它们的字体大小。
例如:将鼠标悬停在标签上,应该更改其字体大小。将鼠标悬停在输入上,也应该更改其字体大小。
为什么不同时改变字体大小呢?我怎样才能实现它?
我正在使用 Weebly 创建一个在线商店,使用模板并遇到了我不喜欢的东西。每次用户单击产品时,都会出现产品页面,如果将鼠标悬停在产品图像上,则会初始化缩放功能。如何禁用此效果?
我有一种感觉,就像 display:none; 一样简单。但我似乎无法弄清楚哪个类或与之相关的任何东西。
我正在尝试更改鼠标悬停时图像的 url,它工作正常,但我正在尝试的是,将鼠标悬停在 div 而不是图像上并更改图像 url
以下jQuery我有:
$(".logo > img").on({
"mouseover" : function() {
this.src = 'images/logo-white.png';
},
"mouseout" : function() {
this.src='images/logo-black.png';
}
Run Code Online (Sandbox Code Playgroud)
超文本标记语言
<div class="logo">
<img src="images/logo-white.png">
</div>
Run Code Online (Sandbox Code Playgroud)
如何使其在 div 上悬停?请帮忙!
我想在用鼠标悬停时在绘图上注释不同的线,这里用点做同样的方式可以使标签在将鼠标悬停在 matplotlib 中的点上时出现吗?
我尝试按如下方式调整此代码:
import matplotlib.pyplot as plt
import numpy as np; np.random.seed(1)
y = np.random.rand(4,15)
x = [np.arange(15) for i in range(len(y))]
names = np.array(list("ABCD"))
fig, ax = plt.subplots()
lines = []
for i in range(len(names)):
lines.append(ax.plot(x[i],y[i]))
annot = ax.annotate("", xy=(0,0), xytext=(20,20),textcoords="offset points",
bbox=dict(boxstyle="round", fc="w"),
arrowprops=dict(arrowstyle="->"))
annot.set_visible(False)
def update_annot(ind):
pos = line.get_offsets()[ind["ind"][0]]
annot.xy = pos
text = "{}, {}".format(" ".join(list(map(str,ind["ind"]))),
" ".join([names[n] for n in ind["ind"]]))
annot.set_text(text)
annot.get_bbox_patch().set_facecolor(cmap(norm(c[ind["ind"][0]])))
annot.get_bbox_patch().set_alpha(0.4)
def hover(event):
vis = annot.get_visible()
if event.inaxes == ax: …Run Code Online (Sandbox Code Playgroud)