-2

I have a text field that is expanding the entire horizontal distance to the window which I don't want. I've tried restricting the size in any way that I can think of:

<input class="searchField" id="searchBar" style="size:10;" type="text" size="10px" value="Search Here" />

with CSS:

#searchBar input
{
    width:10px;
}

.searchField 
{
    size:10px;
}

It is likely that somewhere the other HTML/CSS code is causing it to expand all the way. My question: is there a way to override it so that locally at that input text field, I can have my own size, say 10 pixels?

user1152440
  • 895
  • 2
  • 13
  • 25

5 Answers5

2

Just incase it is targeted with a different width property elsewhere, use

.searchField { width:10px !important; }
Henerz
  • 36
  • 1
  • Just so you know. If this fixes it, it's probably a problem with your CSS. Search your CSS file(s) for the original declaration (.searchField) and try to fix the problem there. – Damien Mar 01 '12 at 20:34
1

Change the width property.

#searchBar { 
  width: 10px; 
}
Brandon
  • 68,708
  • 30
  • 194
  • 223
1

Try using the width css property.

.searchField 
{
     max-width: 10px;
}
Derek Harrington
  • 457
  • 4
  • 13
0

I have never heard of a size CSS property. Do you mean width (say width: 10px)?

dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206
0

'size' is an invalid css property. Use width instead. Give your input a width of 100px for example, 10px is way too little. You may also want to have a look at Input size vs width

Community
  • 1
  • 1
T. Junghans
  • 11,385
  • 7
  • 52
  • 75