1

I use Bootstrap 3, use input group, use button and use glyphicon for the button, but strangely the buttons are not the same height, how do I make the height of the buttons the same?

enter image description here

My simple coding is like this:

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">    
<div class='input-group'>
    <span class='input-group-addon'>Nama</span>
    <input type='text' id='enomor' class='form-control' onkeypress='return okpnons(event)'>
    <span id='enomorupdate'  class='input-group-btn'>
        <button type='button' onclick='ocenomorupdate()' class='btn btn-primary'>
            <span class='glyphicon glyphicon-floppy-disk'></span>
        </button>
    </span>
</div>

1 Answer 1

1

Below is the correct syntax. I've changed the input-group-btn container from a span element to a div element.

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<div class='input-group'>
  <span class='input-group-addon'>Nama</span>
  <input type='text' id='enomor' class='form-control' onkeypress='return okpnons(event)'>
  <div class='input-group-btn'>
    <button type='button' onclick='ocenomorupdate()' class='btn btn-primary'>
      <span class='glyphicon glyphicon-floppy-disk'></span>
    </button>
  </div>
</div>

You can also adjust the height of the button manually to match the height of the bootstrap 3 input using custom CSS:

.input-group .form-control,
.input-group-btn .btn {
    height: 34px;
}
.input-group-addon,
.form-control,
.input-group-btn .btn {
    box-sizing: border-box;
}
7
  • I've tried uploading your coding, but why is it still not working for me? hahahaha, very strange, the height is still different Commented Dec 17, 2023 at 18:19
  • @Junaserbaserbi That suggests you likely either have custom CSS overriding bootstrap styles (which you should include in your question) or you're not using the bootstrap version you specified.
    – Jacob
    Commented Dec 17, 2023 at 18:21
  • <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> I used this before, but I have copied the CSS link from you, but the result is still the same, the height is still different Commented Dec 17, 2023 at 18:29
  • I don't use CSS at all, just the bootstrap.min.css link Commented Dec 17, 2023 at 18:35
  • Let us continue this discussion in chat.
    – Jacob
    Commented Dec 17, 2023 at 18:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.