【发布时间】:2014-04-03 05:08:50
【问题描述】:
我有一个页面,其中.button 将用作虚拟按钮。单击后,它将移动背景图像以执行“悬停动画”。
但是我得到的代码似乎不想做任何事情,并且没有列出任何错误。
$(".button").click(function(){
$(this).css('backgroundPosition', '-468px 0').delay(200).css('background-position', '0 0');
});
我也试过
$(".button").each(function(){
$(this).click(function(){
$(this).css('backgroundPosition', '-468px 0').delay(200).css('background-position', '0 0');
});
});
也试过了
$(".button").each(function(){
$(this).click(function(){
$(this).stop().animate({backgroundPosition: "-468px 0"}, 100);
});
});
CSS
.button {
color: #4e5645;
font-family: 'Roboto', sans-serif;
text-shadow: 0px 0px 1px #b3c799;
text-align: center;
font-size: 32px;
font-weight: bold;
height: 120px;
width: 468px;
line-height: 120px;
background: url(button_hover.png) no-repeat;
cursor: pointer;
}
HTML
<div class="buttonc">
<div class="button">TAX PEOPLE</div>
</div>
有什么想法吗?是的,jQuery 核心已正确链接并用于其他功能。
编辑:作为以下解决方案的替代方案,我今天在自己的写作中偶然发现了这一点……有趣的是,我昨晚没想到悬停按钮。哇。
$(".rightctext").click(function(){
var div = $(this);
div.css('text-shadow', '0px 0px 20px #fbf5df');
setTimeout(function(){
div.css('text-shadow', '0px 0px 10px #474333');
}, 200);
});
【问题讨论】:
-
你的Html和css代码呢,可以分享一下吗?
-
我想不确定这对 javascript 方面有何影响。您只需使用名称来调用它,CSS 不应干扰。一秒钟。
-
看来我忘了在我的 JS 中声明像素。
标签: jquery css image hover click