custom styling textboxes and submit buttons?

Associate
Joined
21 Oct 2008
Posts
1,679
Location
Mooching... in your house
can anyone recommend a decent reliable way to style form components? i have a search box and submit button which at present simply has a background (set in css) and had its borders etc removed... this sort of works but gives different results in different browsers with regards to the positioning on the text...

whats the best way to use bespoke graphics for form elements and have it output correctly on different browsers?
 
I usually opt for:
Code:
<input type="submit" id="submit" value="Submit" />
Code:
input#submit {
  background-color: transparent;
  background-image: url(/image.foo);
  background-repeat: no-repeat;
  width: x;
  height: y;
  border: none;
}
 
custom styling textboxes and submit buttons

You can leave the button value with some reasonable text and style it as follows:
Code:theButtonSelector text-indent:-9999em;overflow:hidden;background:urlpathToImage no-repeat center center;On other hand if you use type="image" not recommended , you can empty the value attribute and add "alt" so those with no images loaded would understand buttons purpose.
 
Back
Top Bottom