1

I am using the bootstrap 4 input group function to place an icon next to an input field. I want to have a fixed width of 40px for input-group-append div (that includes the icon).

The bootstrap docs say "Sizing on the individual input group elements isn’t supported." But I am sure there must be a CSS way of doing it:

<div class="form-group">
  <label>Some label</label>
  <div class="input-group">
    <input type="text" class="form-control"/>
    <div class="input-group-append">
      <i class="icon"></i>
    </div>
  </div>
</div>

Any idea how I can do it?

nimrod
  • 5,595
  • 29
  • 85
  • 149

1 Answers1

1

Try use !important to prevent override

.input-group-append{
width:40px!important;
}
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="form-group">
  <label>Some label</label>
  <div class="input-group">
    <input type="text" class="form-control"/>
    <div class="input-group-append">
      <i class="icon">icon</i>
    </div>
  </div>
</div>
לבני מלכה
  • 15,925
  • 2
  • 23
  • 47