首页 文章

Bootstrap 4 Intl-Tel-Input解决方法

提问于
浏览
0

我正在尝试使用带引导程序4的intl-tel-input . 但是,我根本无法看到输入的占位符 . 我在这个问题上尝试了网上几乎所有可用的解决方案,但不幸的是,没有工作 .

这是我的 HTML

<div class="form-row">
  <div class="form-group col-sm-12">
    <label for="quote-phone" class="sr-only">Mobile Number</label>
    <div class="input-group input-group-lg">
      <input id="phone" type="tel" class="form-control" placeholder="Phone Number">
      <div class="invalid-feedback">
        Please provide a phone number.
      </div>
    </div>
  </div>
</div>

这是我的 CSS

.iti-flag {
    background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.0.3/img/flags.png");
  }

  @media only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (min--moz-device-pixel-ratio: 2),
  only screen and (-o-min-device-pixel-ratio: 2 / 1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
    .iti-flag {
      background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.0.3/img/flags@2x.png");
    }
  }

我的 JS 来初始化插件:

$("#phone").intlTelInput({
  utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.0.3/js/utils.js",
  allowDropdown: true
});

我唯一一次看到占位符就是我这样做的时候:

#phone{
width:100%;
}

但它显然还没有涵盖整行 .

这是JSFiddle link .

有没有解决这个问题的方法?

1 回答

  • 0

    这是因为这个课程的输入宽度为1%:

    .input-group .form-control, .intl-tel-input { width: 100%; }
    

    如果您覆盖该文件,那么您可以看到它 .

相关问题