我遇到以下情况:
我有一个像这样的表结构:
<tr>
<td>text</td>
<td>text</td>
<td>text</td>
<td><a href="#"><img src="#" /></td>
<td><span style="display:hidden"><a href="#">e</a> <a href="#">e</a></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我正在使用以下函数执行的操作是在表格行悬停时显示隐藏的跨度.然而,每当我将childElements悬停在tr:锚定图像和跨度本身时,它就会出现怪癖.我怎样才能解决这个问题?
// Reveal item options on hover
$$('#financedata tr').invoke('observe', 'mouseover', function(event) {
event.target.up().childElements()[4].childElements()[0].toggle();
});
$$('#financedata tr').invoke('observe', 'mouseout', function(event) {
event.target.up().childElements()[4].childElements()[0].toggle();
});
Run Code Online (Sandbox Code Playgroud) 出于某种原因,我不完全确定原因,但以下是行不通的.悬停时背景位置保持不变.我无法弄清楚为什么.我可以用另一种方式做到,但我想尝试找到它为什么不起作用的底部.
#nav a:link, #nav a:visited {
background:url(../img/nav-sprite.png) no-repeat;
display:block;
float:left;
height:200px;
padding:10px;
text-indent:-9999px;
border:solid 1px red;
}
#nav a#home {
background-position:-10px 0px;
width:30px;
}
#nav a#about-us {
background-position:-85px 0px;
width:45px;
}
#nav a:hover {
background-position:1px -15px;
}
Run Code Online (Sandbox Code Playgroud)
有人知道是什么原因引起的吗?
提前致谢!
瑞安
我想检测鼠标在整个文档正文中的移动,并能够准确判断我将鼠标悬停在DOM的哪一部分。“哪个部分”是指鼠标当前位于其最里面的DOM元素。
我可以将鼠标悬停在整个文档主体上,但是$(this)将给我$(body),而不是最里面的元素。或者,我可以递归遍历整个DOM并将鼠标悬停在每个元素上,但这将是对IMO的严重破坏。
有没有简单的方法可以做到这一点?
我希望有人可以救我的!我正在尝试为我的页面创建一个(希望)简单的旋转横幅.我有7个包含照片和文字的div,它们如下:
<div id="content-1">Sample text</div>
<div id="content-2">Sample text</div>
<div id="content-3">Sample text</div>
<div id="content-4">Sample text</div>
<div id="content-5">Sample text</div>
<div id="content-6">Sample text</div>
<div id="content-7">Sample text</div>
Run Code Online (Sandbox Code Playgroud)
在这些div下面我有7个相应的div缩略图:
<div id="thumb-content-1">Sample text</div>
<div id="thumb-content-2">Sample text</div>
<div id="thumb-content-3">Sample text</div>
<div id="thumb-content-4">Sample text</div>
<div id="thumb-content-5">Sample text</div>
<div id="thumb-content-6">Sample text</div>
<div id="thumb-content-7">Sample text</div>
Run Code Online (Sandbox Code Playgroud)
我想做一些事情:
1)每隔5秒循环一次新的div(所以"content-1"将显示5秒,然后是"content 2"等.
2)将一个类应用于名为"cr-rotator"的当前缩略图.我已经设置了风格.
3)当用户将鼠标悬停在主div或缩略图div上时,我希望能够暂停旋转.
4)最后,我想拥有它,如果你将鼠标悬停在缩略图上,它将改变主要内容,然后在鼠标关闭时继续循环.所以说例如你将鼠标悬停在'thumb-content-3'上它将使div'content-3'可见,然后当你鼠标移出它将继续循环.
我知道这里有很多需求,我提前感谢任何可以帮助我的人.我已经提供了一个循环主要图像的脚本,但我不确定如何实现其余的:
var divs = $('div[id^="content-"]').hide(),
i = 0;
(function cycle() {
divs.eq(i).fadeIn(200)
.delay(3000)
.fadeOut(200, cycle);
i = ++i % divs.length; // increment i,
// and reset to 0 when it …Run Code Online (Sandbox Code Playgroud) 我已经为我的Silverlight按钮创建了一个样式模板,设法创建圆角和悬停状态,这会改变大多数样式而没有任何问题,但是......
我无法弄清楚如何Foreground改变颜色hover.
请参阅下面的代码,我遇到问题的部分目前已被注释掉.
<Style TargetType="Button" >
<Setter x:Name="myFontColor" Property="Foreground" Value="#000000"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontStyle" Value="Normal"/>
<Setter Property="FontFamily" Value="Arial"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Height="28">
<Border x:Name="myBorder" BorderBrush="#C4C4C4" BorderThickness="1" CornerRadius="5">
<Rectangle x:Name="BackgroundGradient" RadiusX="5" RadiusY="5">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop x:Name="GradientStop1" Color="#FDFDFD" Offset="0" />
<GradientStop x:Name="GradientStop2" Color="#D6D6D6" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommomStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation
Storyboard.TargetName="GradientStop1"
Storyboard.TargetProperty="Color"
From="#FDFDFD" To="#0A284B" …Run Code Online (Sandbox Code Playgroud) 我有:
当用户单击链接时,当我单击链接的文本时,菜单不会在IE 10/9/8中消失.如果我点击文本周围的间距就会消失.
拉出我的头发试图弄清楚...它在Chrome/IE11中工作正常
这是使其适用于Chrome/IE11的代码:
var $a = _i.$(jqEvent.target);
var $menu = $a.closest('.areaNav');
var $tempBlockOut = _i.$('<div class="tempBlockOut"></div>');
$tempBlockOut.appendTo($menu.parent());
var z = $a.closest('.megamenu').css('z-index');
$tempBlockOut.css({ width: '50px', height: '50px', background: 'transparent', position: 'absolute', 'z-index': z }).position({
of: jqEvent
});
setTimeout(function () {
$tempBlockOut.remove();
}, 100);
Run Code Online (Sandbox Code Playgroud)
我正在放置一个透明的div,光标位于这里,当用户选择一个链接时,hover会被重置并且CSS菜单会消失.
我正在尝试构建一个受golden-spike.com启发的悬停效果(并实际调整其代码).但是有一些麻烦,因为他们的代码使用负z索引,我无法使用,因为我需要在页面上有背景颜色.
这是jsFiddle.您会注意到,如果将.show_img类的z-index更改为-1,则闪烁将完全消失.
这是我目前正在使用的Javascript:
$(document).ready(function() {
var mouseX;
var mouseY;
$(".title").mousemove( function(e) {
mouseX = e.clientX;
mouseY = e.clientY;
});
$(".title").hover(
function () {
$(this).next(".show_img").css("visibility","visible");
$(window).bind('mousemove', function(e){
$(".title").next(".show_img").css({'top':mouseY,'left':mouseX});
});
},
function () {
$(".show_img").css("visibility","hidden");
});
});
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
Flat QPushButtons没有鼠标悬停的迹象.有没有办法为平面按钮悬停状态设置样式,以便它匹配正常按钮悬停状态(或类似的东西)的样式?

如果它意味着偏离默认外观或者必须从头开始设计按钮样式,我不想使用样式表.
我使用独子选择器来显示特定的背景颜色,使用悬停样式来显示不同的背景颜色.问题是,当只有一个孩子时,我不希望悬停样式工作.我怎样才能做到这一点?
1)没有红色背景,但是当我们悬停时它会变为绿色背景
.report p:only-child {
background: red;
}
.report p:hover {
background: green;
}Run Code Online (Sandbox Code Playgroud)
<div class="report">
<p>Test1</p>
<p>Test2</p>
</div>Run Code Online (Sandbox Code Playgroud)
2)红色背景,但我们悬停时没有绿色背景
.report p:only-child {
background: red;
}
.report p:hover {
background: green;
}Run Code Online (Sandbox Code Playgroud)
<div class="report">
<p>Test1</p>
</div>Run Code Online (Sandbox Code Playgroud)
我想显示一个当您将鼠标悬停在某个div时跟随指针的浮动div,到目前为止,我发现这段带有jquery的代码在悬停整个主体时都有效,但是我想要的是在某些div上工作:
的CSS
<div id="tail">mouse tail</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(document).bind('mousemove', function(e){
$('#tail').css({
left: e.pageX + 20,
top: e.pageY
});
});
Run Code Online (Sandbox Code Playgroud)
我尝试bind了特定的选择器,但没有用。
当您将鼠标悬停在div之外时,div应该消失;当您悬停在div上时,div应该重新出现。
hover ×10
css ×5
html ×4
jquery ×4
javascript ×3
button ×1
children ×1
css-sprites ×1
mouseevent ×1
mousemove ×1
prototypejs ×1
pyqt ×1
qpushbutton ×1
qt ×1
rotator ×1
silverlight ×1
transparent ×1