【问题标题】:Menu button vanishes once i click somewhere on the screen一旦我单击屏幕上的某个位置,菜单按钮就会消失
【发布时间】:2015-01-07 18:19:39
【问题描述】:

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>

它工作正常,但是一旦我点击屏幕上的其他地方,我不希望下拉箭头去..

【问题讨论】:

    标签: java html css jsp


    【解决方案1】:
    $('input').on('focusout', function(){
         $(this).height('102px');
         $(this).css("background-color","blue");
    })
    
    $('input').on('focus', function(){
         $(this).height('102px');
         $(this).css("background-color","blue");
    })
    

    使用您的图像而不是背景颜色。

    See the Demo here.

    【讨论】:

      【解决方案2】:

      您可以使用 jquery 来处理它。将此行添加到您的 js 文件中。

      $('input').on('focusout', function(){
          $(this).height('102px');
      })
      

      http://jsfiddle.net/nku0thj3/

      【讨论】:

      • 我试过了,但图像发生了变化。如您所见,每个动作有 3 个单独的图像,高度不同。如果我有 3 个带有单独图像的按钮怎么办?
      • 然后将图像添加到它的焦点上。 $(this).attr('src', '链接到图片');
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-02
      • 1970-01-01
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多