Reputation: 299
I have an textbox with image inside it and i have the textbox and image inside a div. The div covers the exact size of the textbox. Now i need to add an border to the textbox on focus how to do it please help.The code is as below.
<div class="username-bg">
<!-- Sign in here <br/> -->
<!-- Login: -->
<input type="text" id="username" title="Username" maxlength="50" value="" required="true" /><!-- <br/> -->
<img src="user-icon.png" alt="" Class="user-icon"/>
<!-- <img src="images/user-icon.png" alt="" /> -->
</div>
when i try putting onfous border for input text its not showing fully. Please help.
This is how it is now
This is how i want.
Upvotes: 1
Views: 222
Reputation: 1033
try adding a new class called username and password for your input text and put the below jquery it would work fine.
$("body").click(function(event) {
if($(event.target).attr('class') != "username" && $(event.target).attr('class') != "password" && $(event.target).attr('class') != "forgotpass" )
{
$( "#passbg" ).removeClass( "password-bg-focused" ).addClass( "password-bg" );
$( "#userbg" ).removeClass( "username-bg-focused" ).addClass( "username-bg" );
$( "#forgotpass" ).removeClass("username-bg-focused" ).addClass("username-bg" );
}
});
$( ".username" ).focus(function() {
$( "#userbg" ).removeClass( "username-bg" ).addClass( "username-bg-focused" );
$( "#passbg" ).removeClass( "password-bg-focused" ).addClass( "password-bg" );
});
$( ".password" ).focus(function() {
$( "#passbg" ).removeClass( "password-bg" ).addClass( "password-bg-focused" );
$( "#userbg" ).removeClass( "username-bg-focused" ).addClass( "username-bg" );
});
$( ".forgotpass" ).focus(function() {
$( "#forgotpass" ).removeClass( "username-bg" ).addClass( "username-bg-focused" );
});
Upvotes: 1
Reputation: 2462
You need to put outline: none
also on css.
#username:focus {
border: 1px solid green;
outline: none;
}
Demo here: http://jsfiddle.net/libinvbabu/JDsKh/
Upvotes: 0
Reputation: 298
input[type="text"]:focus:hover{
outline: none;
box-shadow: 0px 0px 5px #61C5FA;
border:1px solid #5AB0DB;
border-radius:0;
}
try this i have used it.
Upvotes: 1