Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I control the height of text inputs and submit input buttons in different browsers?

Tags:

html

css

I have a very little but hard (for me) problem to solve.

I have a text input, and a submit button. I need them to be the exact same height and for this to be true across Chrome and Firefox, ideally internet explorer also.

HTML

<input type="text" name="email" /><input type="submit" value="»" />

CSS

input[type=text] {
    width: 218px;
}

input[type=submit] {
    background: #000;
    color: #fff;
}

input[type=submit], input[type=text] {
    padding: 9px;
    font-size: 18px;
    line-height: 18px;
    float: left;
    border: 0;
    display: block;
    margin: 0;
}

I've setup this basic code on a jsfiddle here.

You should notice if you load it in chrome, the button is less height than the text input and in firefox, its larger.

What am I missing?

like image 537
willdanceforfun Avatar asked May 31 '11 07:05

willdanceforfun


People also ask

How do you change the input field height?

If you want to increase the height of the input field, you can specify line-height css property for the input field.

How do you increase input type text height?

fontSize="14pt"; If you simply want to specify the height and font size, use CSS or style attributes, e.g. //in your CSS file or <style> tag #textboxid { height:200px; font-size:14pt; } <!

How do I change the input submit button text?

The attribute that changes the name shown on the Submit Button is the Value attribute. You can change the text that appears on the Submit Button by setting the Value attribute to the desired name you want.

How do you set the length of an input number in HTML?

Input value length You can specify a minimum length (in characters) for the entered value using the minlength attribute; similarly, use maxlength to set the maximum length of the entered value, in characters. The example below requires that the entered value be 4–8 characters in length.


3 Answers

Remove/add line-height: 18px; for both.

like image 174
RRStoyanov Avatar answered Oct 19 '22 18:10

RRStoyanov


Vertical padding of the submit button has no effect. This seems to be a webkit bug. You can solve the problem by specifying explit heights and increasing the height of the submit button by the top and bottom padding of the input field.

input[type=text] {height: 60px;}
input[type=submit] {height: 78px;}
like image 9
phihag Avatar answered Oct 19 '22 19:10

phihag


The problem is your padding that is applying wrong to your button. Trying solving it like this.

input[type=submit], input[type=text] {
  font-size: 18px;
  line-height: 18px;
  float: left;
  border: 0;
  display: block;
  margin: 0;
  height: 30px; /* or whatever height necessary */
}

Additionally, you can keep the padding left and right on your button like this.

input[type=submit] {
  background: #000;
  color: #fff;
  padding: 0px 9px;
}
like image 2
Siebe Avatar answered Oct 19 '22 17:10

Siebe