0

Very simple example of input group:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

  <div class="container">

    <h3>Input Groups</h3>
    <p>The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind it as a "help text".</p>
    <p>The .input-group-addon class attaches an icon or help text next to the input field.</p>

    <form>
      <div class="input-group">
        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
        <input id="email" type="text" class="form-control" name="email" placeholder="Email">
      </div>
      <div class="input-group">
        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
        <input id="password" type="password" class="form-control" name="password" placeholder="Password">
      </div>
      <br>
      <div class="input-group">
        <span class="input-group-addon">Text</span>
        <input id="msg" type="text" class="form-control" name="msg" placeholder="Additional Info">
      </div>
    </form>
    <br>

    <p>It can also be used on the right side of the input:</p>
    <form>
      <div class="input-group">
        <input id="email" type="text" class="form-control" name="email" placeholder="Email">
        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>   
      </div>
      <div class="input-group">
        <input id="password" type="password" class="form-control" name="password" placeholder="Password">
        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
      </div>
    </form>
  </div>

</body>
</html>

It works fine. But when I use latest version(bootstrap 4) the design has been broken.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/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.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>


  <div class="container">

    <h3>Input Groups</h3>
    <p>The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind it as a "help text".</p>
    <p>The .input-group-addon class attaches an icon or help text next to the input field.</p>

    <form>
      <div class="input-group">
        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
        <input id="email" type="text" class="form-control" name="email" placeholder="Email">
      </div>
      <div class="input-group">
        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
        <input id="password" type="password" class="form-control" name="password" placeholder="Password">
      </div>
      <br>
      <div class="input-group">
        <span class="input-group-addon">Text</span>
        <input id="msg" type="text" class="form-control" name="msg" placeholder="Additional Info">
      </div>
    </form>
    <br>

    <p>It can also be used on the right side of the input:</p>
    <form>
      <div class="input-group">
        <input id="email" type="text" class="form-control" name="email" placeholder="Email">
        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>   
      </div>
      <div class="input-group">
        <input id="password" type="password" class="form-control" name="password" placeholder="Password">
        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
      </div>
    </form>
  </div>



</body>
</html>

This two example is 100% identical except bootstrap version. So whats problem with version 4?

Abdus Sattar Bhuiyan
  • 3,016
  • 4
  • 38
  • 72
  • 3
    It is a major version with breaking changes. See: https://getbootstrap.com/docs/4.1/migration/ – Klooven May 15 '18 at 17:01
  • 1
    Look at the link @Klooven added, there are class names that have been removed or changed which is why your design looks messed up. For example .input-group-addon is no longer used and .input-group-prepend is used instead. – crazymatt May 15 '18 at 17:06
  • Thanks. But what about 'glyphicon glyphicon-user'? – Abdus Sattar Bhuiyan May 15 '18 at 17:31
  • See this for Glyphicons migration: https://stackoverflow.com/q/32612690/8918893. I recommend Font Awesome. – Klooven May 15 '18 at 17:32

0 Answers0