Javascript 文本字段的背景色:焦点
我正在尝试制作一个漂亮的文本字段,我想当用户点击它时改变背景颜色。但我想让背景色从左到右慢慢滑动。 这是wordpress的联系方式,但我认为这无关紧要 因此,我想知道我的CSS中有什么:Javascript 文本字段的背景色:焦点,javascript,html,css,wordpress,Javascript,Html,Css,Wordpress,我正在尝试制作一个漂亮的文本字段,我想当用户点击它时改变背景颜色。但我想让背景色从左到右慢慢滑动。 这是wordpress的联系方式,但我认为这无关紧要 因此,我想知道我的CSS中有什么: .brtel { -webkit-transition: width 0.4s ease-in-out; transition: width 0.4s ease-in-out; width: 50px; } .brtel:focus { border-radius: 0px; border:none; ba
.brtel {
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
width: 50px;
}
.brtel:focus {
border-radius: 0px;
border:none;
background:#797d7e;
color: #fff;
width: 200px;
}
我可以在CSS中修复它,还是应该使用JS 您可以使用jquery的简短代码,如下所示
$('.animate').mouseenter(function() {
$(this).addClass('filled');
}).mouseout(function() {
$(this).removeClass('filled')
})
并通过css操作填充的
类
.animate{
display: inline-block;
height: auto!important;
width: 200px;
background: #bbb;
position: relative;
}
.animate:before {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
background: red;
width: 0;
transition: all .5s ease;
}
.animate.filled:before{
width: 100%;
}
input {
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
width: 100%;
-webkit-appearance: none;
appearance: none;
background: none;
border: none;
}
HTML:
<form>
<div class="animate"><input value="Send" type="submit" class="brtel"></div>
</form>
检查这支笔:您可以使用jquery的短代码,如下所示
$('.animate').mouseenter(function() {
$(this).addClass('filled');
}).mouseout(function() {
$(this).removeClass('filled')
})
并通过css操作填充的
类
.animate{
display: inline-block;
height: auto!important;
width: 200px;
background: #bbb;
position: relative;
}
.animate:before {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
background: red;
width: 0;
transition: all .5s ease;
}
.animate.filled:before{
width: 100%;
}
input {
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
width: 100%;
-webkit-appearance: none;
appearance: none;
background: none;
border: none;
}
HTML:
<form>
<div class="animate"><input value="Send" type="submit" class="brtel"></div>
</form>
检查这支笔:我已经在你的类中添加了一个转换元素,你可以在这里看到它
它使背景从白色过渡到灰色,我希望这是您想要的。我已经为您的类添加了一个过渡元素,您可以在这里看到它
它使背景从白色过渡到灰色,我希望这是您想要的。您可以在纯css中完成,但您需要一个具有您想要的颜色作为背景的图像
.brtel {
-webkit-transition: background-size 4s ease-in;
transition: background-size 4s ease-in;
width: 200px;
background-image: url('http://i.imgur.com/9HMnxKs.png');
background-repeat: repeat-y;
background-size: 0% 0%;
}
.brtel:focus {
border-radius: 0px;
border:none;
color: #fff;
background-size: 100% 100%;
}
看这把小提琴:
编辑:拼写您可以在纯css中进行,但您需要一个具有所需颜色作为背景的图像
.brtel {
-webkit-transition: background-size 4s ease-in;
transition: background-size 4s ease-in;
width: 200px;
background-image: url('http://i.imgur.com/9HMnxKs.png');
background-repeat: repeat-y;
background-size: 0% 0%;
}
.brtel:focus {
border-radius: 0px;
border:none;
color: #fff;
background-size: 100% 100%;
}
看这把小提琴:
编辑:拼写你只能用css来实现
<form>
<button type="submit" class="brtel">Send</button>
</form>
.brtel {
position: relative;
}
.brtel:before {
position:absolute;
width: 0;
height: 50px; /* height if input field */
background-color: #666;
display: block;
transition: width .5s ease;
}
.brtel:hover:after {
width: 100%;
}
发送
布特尔先生{
位置:相对位置;
}
布莱特:以前{
位置:绝对位置;
宽度:0;
高度:50px;/*输入字段的高度*/
背景色:#666;
显示:块;
过渡:宽度。5s轻松;
}
.brtel:悬停:之后{
宽度:100%;
}
您只能通过css实现这一点
<form>
<button type="submit" class="brtel">Send</button>
</form>
.brtel {
position: relative;
}
.brtel:before {
position:absolute;
width: 0;
height: 50px; /* height if input field */
background-color: #666;
display: block;
transition: width .5s ease;
}
.brtel:hover:after {
width: 100%;
}
发送
布特尔先生{
位置:相对位置;
}
布莱特:以前{
位置:绝对位置;
宽度:0;
高度:50px;/*输入字段的高度*/
背景色:#666;
显示:块;
过渡:宽度。5s轻松;
}
.brtel:悬停:之后{
宽度:100%;
}
您只能通过CSS实现
请检查下面的代码
.brtel {
width: 150px;
}
.brtel:focus {
border-radius: 0px;
border:none;
background:#797d7e;
color: #fff;
animation: equalize .4s 0s 1;
}
@keyframes equalize {
0% {
width: 10px;
}
10% {
width: 20px;
}
20% {
width: 30px;
}
30% {
width: 40px;
}
40% {
width: 50px;
}
50% {
width: 60px;
}
60% {
width: 70px;
}
70% {
width: 80px;
}
80% {
width: 90px;
}
90% {
width: 100px;;
}
100% {
width: 100px;
}
}
<form id="formoid" action="/" title="" method="post">
<div>
<label class="title">First Name</label>
<input type="text" id="name" name="name" class="brtel">
</div>
</form>
.brtel{
宽度:150px;
}
布莱特尔:焦点{
边界半径:0px;
边界:无;
背景#797d7e;
颜色:#fff;
动画:均衡。4s0s1;
}
@关键帧均衡{
0% {
宽度:10px;
}
10% {
宽度:20px;
}
20% {
宽度:30px;
}
30% {
宽度:40px;
}
40% {
宽度:50px;
}
50% {
宽度:60px;
}
60% {
宽度:70px;
}
70% {
宽度:80px;
}
80% {
宽度:90px;
}
90% {
宽度:100px;;
}
100% {
宽度:100px;
}
}
名字
您只能通过CSS实现
请检查下面的代码
.brtel {
width: 150px;
}
.brtel:focus {
border-radius: 0px;
border:none;
background:#797d7e;
color: #fff;
animation: equalize .4s 0s 1;
}
@keyframes equalize {
0% {
width: 10px;
}
10% {
width: 20px;
}
20% {
width: 30px;
}
30% {
width: 40px;
}
40% {
width: 50px;
}
50% {
width: 60px;
}
60% {
width: 70px;
}
70% {
width: 80px;
}
80% {
width: 90px;
}
90% {
width: 100px;;
}
100% {
width: 100px;
}
}
<form id="formoid" action="/" title="" method="post">
<div>
<label class="title">First Name</label>
<input type="text" id="name" name="name" class="brtel">
</div>
</form>
.brtel{
宽度:150px;
}
布莱特尔:焦点{
边界半径:0px;
边界:无;
背景#797d7e;
颜色:#fff;
动画:均衡。4s0s1;
}
@关键帧均衡{
0% {
宽度:10px;
}
10% {
宽度:20px;
}
20% {
宽度:30px;
}
30% {
宽度:40px;
}
40% {
宽度:50px;
}
50% {
宽度:60px;
}
60% {
宽度:70px;
}
70% {
宽度:80px;
}
80% {
宽度:90px;
}
90% {
宽度:100px;;
}
100% {
宽度:100px;
}
}
名字
这就是我想要的,伟大的解决方案。这就是我想要的,伟大的解决方案。