Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom html input box on focus issue

Tags:

html

css

I am trying to develop a HTML input box like the below image:

Normal input.

I made it using the following code:

input[type=text] {
    background: transparent;
    border: none;
    border-bottom: 1px solid #000000;
     padding: 2px 5px;
}
input[type=text]:focus
{
    border: none;
    border-bottom: 1px dashed #D9FFA9;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>

  Name :  <input type="text" />
  
</body>
</html>

ISSUE:
Here when I focus the input box, and start entering text a blue border is appearing around the input box as shown in below image.

I have to remove this blue border box. How to do it?
enter image description here

like image 603
rusty bit Avatar asked Feb 20 '16 06:02

rusty bit


People also ask

How do you focus an input box in HTML?

Input Text focus() MethodThe focus() method is used to give focus to a text field. Tip: Use the blur() method to remove focus from a text field.

How do you focus on input element?

To set focus to an HTML form element, the focus() method of JavaScript can be used. To do so, call this method on an object of the element that is to be focused, as shown in the example. Example 1: The focus() method is set to the input tag when user clicks on Focus button.

How do you hide input border on focus?

Answer: Use CSS outline property In Google Chrome browser form controls like <input> , <textarea> and <select> highlighted with blue outline around them on focus. This is the default behavior of chrome, however if you don't like it you can easily remove this by setting their outline property to none .


1 Answers

Add outline: 0 to your css

input[type=text] :focus
{
    border: none;
    border-bottom: 1px dashed #D9FFA9;
    outline: 0;
}

I will add that this is there for a purpose and shows a user when the input is focused - It's good practice to style it (change color for example), not remove it

like image 167
StudioTime Avatar answered Oct 05 '22 10:10

StudioTime