2

I have a link and a button sitting next to each other on a page. The CSS code effecting them is identical, but the input is just a bit shorter in height than the input - any suggestions about how to make them the exact same height? JSFiddle

HTML:

<input type="submit" value="Input"> <a href="#">Link</a>

CSS:

input[type="submit"], a:link, a:visited {
background-color: #4eb4df;
border: none;
  font-family: arial;
  color: #ffffff;
  border-radius: 4px;
  padding: 5px 20px;
  font-size: 1.2em;
  text-shadow: 1px 1px #6d6d6d;
  display: inline-block;
  margin: 30px auto 10px;
  text-transform: uppercase;
  text-decoration: none;
}
input[type="submit"]:hover, input[type="submit"]:active, a:hover, a:active {
  background-color: #3e94b9;
}
www139
  • 4,960
  • 3
  • 31
  • 56
user44531
  • 47
  • 7

3 Answers3

1

The link is shorter because the text on it is shorter. If you want to force a width, You can add a value of width or min-width. In this case you will also want to get rid of the left and right padding, and probably align the text in the center.

input[type="submit"], a:link, a:visited {
    min-width: 100px
    padding: 5px 0;
    text-align: center;
}
1

Firefox appears to render the height of input elements differently than other browsers. This is very annoying but the code below explains about how to remove the added height.

I did some research and figured it out. It appears to be a bug with Firefox. Here is a another question which covers it Buttons too tall on Firefox. Here is an article which explains with more information http://davidwalsh.name/firefox-buttons.

Here is a jsfiddle https://jsfiddle.net/www139/e9gg7ncu/2/.

Here is a code snippet (remember that this is only relevant to the Firefox browser).

input[type="submit"], a:link, a:visited {
    background-color: #4eb4df;
    border: none;
    font-family: arial;
    color: #ffffff;
    border-radius: 4px;
    padding: 5px 20px;
    font-size: 1.2em;
    text-shadow: 1px 1px #6d6d6d;
    display: inline-block;
    margin: 30px auto 10px;
    text-transform: uppercase;
    text-decoration: none;
    font-size:1em;
}
input[type="submit"]:hover, input[type="submit"]:active, a:hover, a:active {
    background-color: #3e94b9;
}
input::-moz-focus-inner /*Remove button padding in FF*/
{ 
    border: 0;
    padding: 0;
}
<input type="submit" value="Input"> <a href="#">Link</a>
Community
  • 1
  • 1
www139
  • 4,960
  • 3
  • 31
  • 56
0

Edit the class to the following, set the width to be the same and make sure you use box-sizing so that the width and height includes content, padding and border.

input[type="submit"], a:link, a:visited {
    background-color: #4eb4df;
    border: none;
    font-family: arial;
    color: #ffffff;
    border-radius: 4px;
    padding: 5px 20px;
    font-size: 1.2em;
    text-shadow: 1px 1px #6d6d6d;
    display: inline-block;
    margin: 30px auto 10px;
    text-transform: uppercase;
    text-decoration: none;
    text-align:center;
    width:250px;
    box-sizing:border-box;
}
Benneb10
  • 1,419
  • 1
  • 8
  • 13