Java 一旦我点击屏幕上的某个地方,菜单按钮就会消失
css代码我为每个效果添加了图像Java 一旦我点击屏幕上的某个地方,菜单按钮就会消失,java,html,css,jsp,Java,Html,Css,Jsp,css代码我为每个效果添加了图像 #button3 { border:none; outline:none; width:262px; height:66px; background:url("settings_button1.png"); position:absolute; margin-left:515px; } #button3:hover { width:262px; height:66px;
#button3
{ border:none;
outline:none;
width:262px;
height:66px;
background:url("settings_button1.png");
position:absolute;
margin-left:515px;
}
#button3:hover
{
width:262px;
height:66px;
background:url("settings_button2.png");
}
#button3:focus
{
width:262px;
height:102px;
background:url("settings_button3.png");
}
HTML代码
<html>
<head>
</head>
<body>
<input type="button" id="button3">
</body>
</html>
它工作正常,但一旦我在屏幕上单击其他地方,我就不想让下拉箭头移动。您可以使用jquery处理它。将这一行添加到js文件中
$('input').on('focusout', function(){
$(this).height('102px');
})
使用图像而不是背景色
我试过了,但是图像发生了变化。正如你所看到的,每个动作有3个不同的图像,高度也不同。如果我有3个按钮,上面有不同的图像怎么办?然后在调焦时将图像添加到其中$(this.attr('src','linktoimage');
$('input').on('focusout', function(){
$(this).height('102px');
$(this).css("background-color","blue");
})
$('input').on('focus', function(){
$(this).height('102px');
$(this).css("background-color","blue");
})