Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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
Jquery 具有全页覆盖效果的滑动搜索框_Jquery_Overlay_Slide_Search Box - Fatal编程技术网

Jquery 具有全页覆盖效果的滑动搜索框

Jquery 具有全页覆盖效果的滑动搜索框,jquery,overlay,slide,search-box,Jquery,Overlay,Slide,Search Box,我想在我自己的网站上实现这种搜索框(点击顶部菜单中的“cerca”): 这种水平滑动效果是如何在单击时显示searchform和fullpage叠加效果的 你知道这方面的一些教程吗?或者你能帮我做一些吗 提前非常感谢你, Démian P.这只是一种滑动效果,只要用户鼠标在文本框内聚焦,jquery就会通过动画增加文本框的宽度。这里有一个例子 假设您的文本框是: <input type="text" id="textbox" style="width: 100px;" /> 数据默

我想在我自己的网站上实现这种搜索框(点击顶部菜单中的“cerca”):

这种水平滑动效果是如何在单击时显示searchform和fullpage叠加效果的

你知道这方面的一些教程吗?或者你能帮我做一些吗

提前非常感谢你,
Démian P.

这只是一种滑动效果,只要用户鼠标在文本框内聚焦,jquery就会通过动画增加文本框的宽度。这里有一个例子

假设您的文本框是:

<input type="text" id="textbox" style="width: 100px;" />
数据默认值用于存储温度值

类似的内容

当然你可以改进更多的风格

html:

js:

我更喜欢悬停:)

HTML:

  <ul id="nav">
       
    <li><a href="#">portfolio. </a></li>
    <li><a href="#">agenzia. </a></li>
    <li><a href="#">contatti. </a></li>
    <li id="search"><a href="#">cerca.</a><input type="text" placeholder="Entra un termine" /></li>
    <li></li>

  </ul>
/* OVERLAY */

#overlay{
  position:absolute;
  z-index:9; /*input is 10*/
  display:none;
  width:100%;
  height:100%;
  background:url(http://www.solidstudio.it/wp-content/themes/solid/css/images/mask_black.png);
}

/* PAGE */
a{text-decoration:none;}

#nav{
  list-style:none;
  padding:0;
}
#nav li{
  position:relative;
  float:left;
  padding:40px 5px;
  cursor:pointer;
}
#nav li:hover{
  background:#000;
}
#nav li:hover a{
  color:#fff;
  border-bottom:1px solid #fff;
}
#nav a{
  display:block;
  border-bottom:1px solid #000;
  width:100px;
  margin:10px;
  color:#000;
  padding-bottom:10px;
}
li#search{
  z-index:10;
}
#nav input{
  display:none;
  position:absolute;
  top:50px;
  left:15px;
  background:transparent;
  border:none;
  border-bottom:1px solid #fff;
  height:31px;
  width:230px;
  color:#0ff;
  font-size:21px;
  font-family:Century Gothic, sans-serif;
  font-weight:400;
}
$('#search').on('mouseenter mouseleave', function( e ){
  var mEnt      = e.type=='mouseenter';
  
  var opacity   = mEnt ? 1      : 0      ;
  var width     = mEnt ? 250    : 100    ;
  var show_hide = mEnt ? 'show' : 'hide' ;
  
  $(this).stop().animate({width: width}, 400);
  $('a', this).stop().fadeTo(400, !opacity);
  $('input', this).stop().fadeTo(400,opacity);
  $('#overlay').stop().fadeTo(400, opacity, function(){
    $(this)[show_hide]();
  });
  
}); 
jQuery:

  <ul id="nav">
       
    <li><a href="#">portfolio. </a></li>
    <li><a href="#">agenzia. </a></li>
    <li><a href="#">contatti. </a></li>
    <li id="search"><a href="#">cerca.</a><input type="text" placeholder="Entra un termine" /></li>
    <li></li>

  </ul>
/* OVERLAY */

#overlay{
  position:absolute;
  z-index:9; /*input is 10*/
  display:none;
  width:100%;
  height:100%;
  background:url(http://www.solidstudio.it/wp-content/themes/solid/css/images/mask_black.png);
}

/* PAGE */
a{text-decoration:none;}

#nav{
  list-style:none;
  padding:0;
}
#nav li{
  position:relative;
  float:left;
  padding:40px 5px;
  cursor:pointer;
}
#nav li:hover{
  background:#000;
}
#nav li:hover a{
  color:#fff;
  border-bottom:1px solid #fff;
}
#nav a{
  display:block;
  border-bottom:1px solid #000;
  width:100px;
  margin:10px;
  color:#000;
  padding-bottom:10px;
}
li#search{
  z-index:10;
}
#nav input{
  display:none;
  position:absolute;
  top:50px;
  left:15px;
  background:transparent;
  border:none;
  border-bottom:1px solid #fff;
  height:31px;
  width:230px;
  color:#0ff;
  font-size:21px;
  font-family:Century Gothic, sans-serif;
  font-weight:400;
}
$('#search').on('mouseenter mouseleave', function( e ){
  var mEnt      = e.type=='mouseenter';
  
  var opacity   = mEnt ? 1      : 0      ;
  var width     = mEnt ? 250    : 100    ;
  var show_hide = mEnt ? 'show' : 'hide' ;
  
  $(this).stop().animate({width: width}, 400);
  $('a', this).stop().fadeTo(400, !opacity);
  $('input', this).stop().fadeTo(400,opacity);
  $('#overlay').stop().fadeTo(400, opacity, function(){
    $(this)[show_hide]();
  });
  
}); 

谢谢大家:帕里托斯,罗克森,马特·米海!我使用了roXon的代码,它工作得很好。感谢您允许我找到解决方案并了解更多信息。
$('#search').on('mouseenter mouseleave', function( e ){
  var mEnt      = e.type=='mouseenter';
  
  var opacity   = mEnt ? 1      : 0      ;
  var width     = mEnt ? 250    : 100    ;
  var show_hide = mEnt ? 'show' : 'hide' ;
  
  $(this).stop().animate({width: width}, 400);
  $('a', this).stop().fadeTo(400, !opacity);
  $('input', this).stop().fadeTo(400,opacity);
  $('#overlay').stop().fadeTo(400, opacity, function(){
    $(this)[show_hide]();
  });
  
});