我试图在悬停时删除链接的标题属性,然后在鼠标移出时将其添加回来.我想将var hoverText传递给悬停...
这是我的代码.有任何想法吗?
$(".icon a").hover(function() {
$this = $(this);
var hoverText = $.data(this, 'title', $this.attr('title'));
$(this).find("em").animate({opacity: "show", top: "-35"}, "slow");
$(this).find("em").text(hoverText);
$this.removeAttr('title');
}, function(hoverText) {
$(this).find("em").animate({opacity: "hide", top: "-45"}, "fast");
$(this).attr("title", hoverText);
});
Run Code Online (Sandbox Code Playgroud) 在悬停时,我想在图像的右上角有一个链接.就像你在Facebook上的个人资料图片上所说的"改变图片"一样.
我试图让它使用一些jquery,但没有运气,因为它没有图像的右侧.图像将是不同的大小,因为它们是个人资料图片.无论大小如何,它都需要保持在图像的右上角.
JQuery的:
$(".imgHover").hover(function() {
$(this).children("img").fadeTo(200, 0.25)
.end().children(".hover").show();
}, function() {
$(this).children("img").fadeTo(200, 1)
.end().children(".hover").hide();
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="imgHover">
<div class="hover"><a href="htpp://google.com">Edit</a></div>
<img src="http://img14.imageshack.us/img14/9698/29588166.jpg" alt="" />
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.imgHover .hover {
display: none;
position:absolute;
z-index: 2;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在构建一个应用程序,允许您通过单击它们将列表项从一个列表移动到另一个列表.但是,为了让用户知道clik的预期动作是什么,我在CSS中设置了一个:悬停状态,显示诸如"<< move"之类的指令
然而,我发现的问题是,在Internet Explorer(测试版本7-9)中,当我移动DOM元素时:该元素的悬停状态保持(变得粘滞),即使鼠标移动也是如此.:当用户将鼠标悬停在其新位置的项目上然后将鼠标移开时,悬停状态才会消失.这似乎是Internet Explorer唯一的问题.
如果您使用IE浏览器,请访问http://jsfiddle.net/hc2Eu/32/
当然有一种解决方法是不使用CSS:悬停状态并使用JQuery悬停事件代替,但这肯定不是最好的做事方式,并保持元素:在CSS中控制的悬停状态是远远的最强有力的做法.解决方法可以在http://jsfiddle.net/hc2Eu/29/上看到
有没有人想出我怎么能告诉Internet Explorer某个元素不再在鼠标下面,它应该释放:悬停状态?
马特
我有一个在悬停时有一些css3动画的网页,当用户触摸这些元素时,我想让它在iPad(和任何支持触摸的设备)上工作.
这是我的代码:
HTML:
<div id="headBlock">
<a id="arm"></a>
<div id="head">
<div id="blink"></div>
<div id="lid"></div>
<div id="man"></div>
<a id="man-arm"></a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
//arm
$('#arm').hover(function(){
$(this).removeAttr('style').css('bottom','244px');
$(this).addClass('hover_effect');
}, function(){
$(this).removeClass('hover_effect');
});
//man arm
$('#man').hover(function(){
$('#man-arm').removeAttr('style');
$('#man-arm').addClass('hover_effect');
}, function(){
$('#man-arm').removeClass('hover_effect');
});
Run Code Online (Sandbox Code Playgroud)
您可以看到,当鼠标输入元素时,我删除了样式,然后应用样式并添加css类'hover_effect',当鼠标离开时,我删除'hover_effect'类.
如何在触摸设备上实现相同的功能?click事件没有回调,因此在单击发生后我无法删除'hover_effect'类.我尝试了mousedown和mouseup但它没有用.我搜索了stackoverflow,我发现了这个如何使用触摸启用浏览器来模拟悬停?但它没有任何效果.
任何想法的人?
谢谢
毛罗
我试图在悬停时更改按钮内的文本颜色.
我可以让按钮本身改变颜色,但我希望按钮文本也改变颜色.
这是我目前的css:
button,
input.button,
a.button,
input[type="submit"] {
background:#2e77ae;
background: -moz-linear-gradient(top, #5590bd, #2e77ae);
background: -webkit-linear-gradient(top, #5590bd, #2e77ae);
background: -o-linear-gradient(top, #5590bd, #2e77ae);
background: -ms-linear-gradient(top, #5590bd, #2e77ae);
background: linear-gradient(top, #5590bd, #2e77ae);
border-color:#2e77ae;}
button:hover,
input.button:hover,
a.button:hover,
input[type="submit"]:hover{
background:#E6D332;
background: -moz-linear-gradient(top, #E6D332, #E6D332);
background: -webkit-linear-gradient(top, #E6D332, #E6D332);
background: -ms-linear-gradient(top, #E6D332, #E6D332);
background: linear-gradient(top, #E6D332, #E6D332);
border-color:#2e77ae;}
button:focus,
input.button:focus,
a.button:focus,
input[type="submit"]:focus {
background-color:#E6D332;}
Run Code Online (Sandbox Code Playgroud) 我正在探索如何设置表格的样式,以便当鼠标悬停在列上时可以更改边框.

当鼠标位于列上时,我想通过更改边框颜色来突出显示该列:

为了突出显示,我在jQuery库中使用以下JavaScript代码:
$('td').hover(function() {
var t = parseInt($(this).index()) + 1;
$('td:nth-child(' + t + ')').addClass('highlighted');
},
function() {
var t = parseInt($(this).index()) + 1;
$('td:nth-child(' + t + ')').removeClass('highlighted');
});
Run Code Online (Sandbox Code Playgroud)
使用以下CSS:
.highlighted {
border-top: 2px solid black;
border-right: 2px solid black;
border-left: 2px solid black;
}
Run Code Online (Sandbox Code Playgroud)
您可以在这个JSFiddle中查看它是如何工作的:http://jsfiddle.net/sCFjj/1/ 这仅在我将鼠标悬停在最左侧列时才有效.否则,它会突出显示右列(和顶部),但不会突出显示左侧垂直列.有没有办法让左垂直列出现?
理想情况下,我希望效果忽略最低行,但我不确定如何从jQuery选择中排除一行.
我的尝试是基于前一个问题.
我试图在悬停时更改xaml中按钮样式的背景颜色这是我当前的方法,但它不起作用.正在使用默认的悬停颜色
<Style x:Key="AtStyle" TargetType="Button">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{StaticResource AtBlue}" />
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="12,6" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="18.667" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Red" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
我已经看到其他解决方案,你需要覆盖控制模板来实现这一点,但这些解决方案还需要你定义边框和内容,这似乎是不必要的.在Xaml中定义悬停状态的最小方法是什么?
这样有一个SVG元素 -
<path d="M0,5.26429605180997L6.078685485212741,-5.26429605180997 -6.078685485212741,-5.26429605180997Z" transform="translate(100,100)scale(0.8)" style="fill: rgb(0, 0, 0);"></path>
Run Code Online (Sandbox Code Playgroud)
现在,这个元素非常小,在它上面盘旋非常困难.
如何增加悬停区域(保持此元素的区域相同),以便即使鼠标指向大约2 px,hover事件也会被触发?
更新10/3/2018:这不是R独有的.它之前已被报道,目前被标记为功能请求,在这里:https://github.com/plotly/plotly.js/issues/260
我正在为r中的plotly图形添加散点图点的自定义悬停文本.它似乎是将文本左对齐,居中对齐或右对齐,具体取决于文本框是分别显示在绘图点的右侧,中间还是左侧.无论盒子的位置如何,我都希望文本始终对齐.我已经能够设置字体样式,例如设置颜色和大小,但无法更改文本对齐方式.
这是一个MRE.我删除了传说,所以最右边的点被迫让他们的悬停框出现在点的左边.
plot_ly(iris,
x = ~Sepal.Length,
y = ~Sepal.Width,
type = 'scatter',
mode = 'markers',
hoverinfo = 'text',
hoverlabel = list(font = list(color = 'white')),
text = ~paste0('Some rather long text',
'\nSepal.Length: ', Sepal.Length,
'\nSepal.Width: ', Sepal.Width)) %>%
layout(showlegend = FALSE)
Run Code Online (Sandbox Code Playgroud)