Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to style a TextBox in CSS [closed]

Tags:

html

css

class

I would like to hear what's the best thing to do with pure CSS.

The Situation:

I'm having a textbox in which i can search for specific items. Yet now i'm also having an advanced search with almost the same textbox yet the width of the advancedSearchTextbox is less than the default one.

My Question

What is the best way to style the textbox?

My Solution

I've fixed this now like this:

.defaultTextBox {
    padding: 0;
    height: 30px;
    position: relative;
    left: 0;
    outline: none;
    border: 1px solid #cdcdcd;
    border-color: rgba(0,0,0,.15);
    background-color: white;
    font-size: 16px;
}
.advancedSearchTextbox {
    width: 526px;
    margin-right: -4px;
}

and then in the HTML it'd look something like this for the advancedSearchTextbox:

<input type="text" class="defaultTextBox advancedSearchTextBox" />

Is this the best way to do it? Or are there any other options available? As for just 1 other textbox it's do-able but what if i need more textboxes on other pages?

Thanks in advance :)!

like image 666
Baklap4 Avatar asked Dec 24 '13 18:12

Baklap4


People also ask

How do you cover a text box in HTML?

The "type="hidden"" would hide it. I've meant to explain it in your answer...

How do you style text inside input field?

Styling Input Fields If you only want to style a specific input type, you can use attribute selectors: input[type=text] - will only select text fields. input[type=password] - will only select password fields. input[type=number] - will only select number fields.

How do you apply inline style?

An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.


1 Answers

You could target all text boxes with input[type=text] and then explicitly define the class for the textboxes who need it.

You can code like below :

input[type=text] {
  padding: 0;
  height: 30px;
  position: relative;
  left: 0;
  outline: none;
  border: 1px solid #cdcdcd;
  border-color: rgba(0, 0, 0, .15);
  background-color: white;
  font-size: 16px;
}

.advancedSearchTextbox {
  width: 526px;
  margin-right: -4px;
}
<input type="text" class="advancedSearchTextBox" />
like image 89
Neograph734 Avatar answered Oct 08 '22 17:10

Neograph734