Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 一旦我点击屏幕上的某个地方,菜单按钮就会消失_Java_Html_Css_Jsp - Fatal编程技术网

Java 一旦我点击屏幕上的某个地方,菜单按钮就会消失

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;

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;
     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");
})