如何将一个输入栏推开
how to push an input bar out of the way of another?
我不确定这是否可能,但我有这两个相邻的输入栏。我试着让其中一个酒吧一直开着,直到点击另一个,然后第一个酒吧关闭,它也一直开着。我有一些类似的使用"自动对焦"转换的功能,但当你点击我的网站时,栏就会关闭。
如果有人能做到这一点,javascript将非常有效
Fiddle
有什么帮助吗?
HTML:
<div id='Sidebar'>
<div id='SMBar'>
<div id="input-bars">
<!-- SEARCH BAR -->
<div id="SearchBar">
<form id="tfnewsearch" method="get" action="URL">
<input type="text" class="search-text-input" placeholder="Search Posts..." name="q" />
</form>
<div class="tfclear"></div>
</div>
<!-- EMAIL BAR -->
<div id="FollowByEmail1">
<form action="URL" method="post" target="popupwindow" onsubmit="window.open('URL', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
<p>
<input autofocus="autofocus" class="follow-by-email-address" placeholder="Updates by Email..." type="text" name="email" />
</p>
<input type="hidden" value="" name="uri" />
<input type="hidden" name="loc" value="en_US" />
</form>
</div>
</div>
</div>
CSS:
#Sidebar {
width: 270px;
border: 1px solid transparent;
height: 500px;
}
#SMBar {
border: 1px solid transparent;
margin: 5px;
height: 405px;
}
#input-bars {
border: 1px solid transparent;
margin: 5px;
height: 30px;
}
input {
height: 25px;
font-size: 14px;
font-family: Play;
padding-left: 30px;
width: 0px;
transition-property: width;
transition-duration: 1s;
background-repeat: no-repeat;
border-radius: 5px;
border: 1px solid black;
outline: none;
box-shadow: 0px 0px 9px #dddddd;
-moz-box-shadow: 0px 0px 9px #dddddd;
-webkit-box-shadow: 0px 0px 9px #dddddd;
}
input:focus {
width: 170px;
box-shadow: 0px 0px 4px #000000;
-moz-box-shadow: 0px 0px 4px #000000;
-webkit-box-shadow: 0px 0px 4px #000000;
}
.follow-by-email-address {
background-image: url(http://imageshack.com/a/img703/8868/iavu.png);
padding-left: 30px;
margin: -12px 0px 0px 2px;
float: left;
}
.search-text-input {
background-image: url(http://imageshack.com/a/img34/9278/cw35.png);
padding-left: 30px;
float: right;
margin: 0px 2px 0px 0px;
}
下面是一个使用jQuery DEMO 的示例
我将.follow-by-email-address
的初始宽度更改为170px,并删除了input:focus
CSS选择器,然后添加了此脚本。
$(document).ready(function(){
$('.follow-by-email-address').focus(function(){
$(this).animate({
width: 170
}, 500);
$('.search-text-input').animate({
width: 0
},500);
});
$('.search-text-input').focus(function(){
$(this).animate({
width: 170
}, 500);
$('.follow-by-email-address').animate({
width: 0
},500);
});
});
相关文章:
- javascript函数,它接受两个输入:一个对象和一个键,并返回对象中该键的相应值
- 用户在文本框中输入一个数字,并根据使用 PHP 输入的数字重定向到另一个网页
- 如何要求用户输入一个介于 1 和 50 之间的整数,然后小程序打印出一行这个星数
- Javascript提示和警报输入一个数字,它将循环,您将输入数字以获得它的平均值
- 如果使用jquery输入一个字段,则自动填充其他字段
- 一直要一个数字,直到输入一个偶数
- 需要用户输入一个随机数,然后提醒用户数字 ibnputted
- 以 jQuery 为中心的文本框在 Safari 中输入一个字符后失去焦点
- 如何将我的 Google 地图功能从自动查找我的位置更改为让我输入一个位置
- 如何让两个不同的输入(一个用于移动设备,一个用于桌面)修改同一变量
- 允许html输入框只输入一个完整的数字和精确的十进制.5
- 我怎样才能使我的表单输入不返回任何结果,当它输入一个空查询
- 用TypeScript输入一个约束字典
- 只有在用户输入一个字符后,AngularJS才会调用数据库
- 在javascript中输入一个正斜杠
- 如何使移动
- 如何确保用户在Javascript中输入一个有效的数字
- Rails 3 -设计'请输入一个电子邮件地址'弹出消息,即使禁用了validatable
- 在输入中输入一个值
- 输入一个返回的可观察对象