输入 "center" 在 Bootstrap 中无效 4

Input "center" not working in Bootstrap 4

事实上,我正在学习 bootstrap,当我想要将输入居中时。它不是中心。

奇怪……是我的版本问题?

<!DOCTYPE html>
<html>
   <head>
      <title>HTML CSS JS</title>
      <link
         href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
         rel="stylesheet"
         />
   </head>
   <body>
      <div class="form-group">
         <div class="d-flex justify-content-center">
            <input type="text" class="form-control" />
            <span class="input-group-btn">
            <button class="btn btn-primary" type="button">Go!</button>
            </span>
         </div>
      </div>
   </body>
</html>

我想你只需要给你的输入一个大小。

如果你没有给输入某种宽度,它将是行内块,你需要全宽度。

<!DOCTYPE html>
<html>
   <head>
      <title>HTML CSS JS</title>
      <link
         href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
         rel="stylesheet"
         />
   </head>
   <body>
      <div class="form-group ">
         <div class="d-flex justify-content-center">
            <input type="text" class="form-control" style="width: 30%" />
            <span class="input-group-btn">
            <button class="btn btn-primary" type="button">Go!</button>
            </span>
         </div>
      </div>
   </body>
</html>