你能帮我解决这个问题吗?我在 bootstrap 4 中有一个 input-group
。在我的 input-group
我有 2 个输入,第一个是前置,第二个是附加。
It’s wrapped in a col-12
div
in a form-group
and I need to set the width
of the first input and second to some specific (但不同)价值。我试图在我的自定义 css 中设置 width
,但没有成功。可能吗?我知道,我可以通过将它与另一个 col 包装在一个 div 中来设置它,但是我在下面输入了两个输入,而不是并排输入。
代码:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="form-group">
<label for="telephone">Telephone</label>
<div class="row">
<div class="col-12">
<div class="input-group telephone-input">
<div class="input-group-prepend preselection-prepend">
<div class="input-group-text">+</div>
</div>
<input class="form-control" id="preselection" type="text" maxlength="3" name="preselection" placeholder="Preselection" autocomplete="off" required>
<input class="form-control" id="telephone" placeholder="Telephone number" type="tel" maxlength="11" name="telephone" autocomplete="off" required>
<span class="placeholder" id="tele-holder"></span>
<div class="input-group-append" id="preselectionToggle">
<div class="input-group-text">
<i class="far fa-plus-square"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" integrity="sha384-SlE991lGASHoBfWbelyBPLsUlwY1GwNDJo3jSJO04KZ33K2bwfV9YBauFfnzvynJ" crossorigin="anonymous"></script>
原文由 Ondřej Javorský 发布,翻译遵循 CC BY-SA 4.0 许可协议
我找到了解决办法。我尝试设置最大宽度而不是仅设置宽度并且它有效。对于上面的例子,它将是: