html - Boostrap 和 Html - 为什么一个输入框是全宽的而其他输入框那么短?
问题描述
为什么一个输入框是全宽的,而其他的那么短?这是我的html。我正在使用引导程序:
<form action="https://www.example.net/auth/create_user" class="form-horizontal" id="login-attempts-form-admin method="post" accept-charset="utf-8">
<div class="container">
<div class="row">
<div class="col-sm-6 col-xs-6">
<!-- id -->
<div class="form-group">
<label for="id">
Reference Id
</label>
<div class="input-group">
<input type="text" name="id" value="" id="id" style="" class="form-control" placeholder="" disabled="disabled" />
<div class="input-group-addon"><i class="ti-info"></i>
</div>
</div> <!-- end input group -->
<span class="help-block">
The Reference Id is created automatically.
</span>
</div> <!-- end form-group Id -->
<!-- ip_address -->
<div class="form-group">
<label for="ip_address">
IP Address
</label>
<div class="input-group">
<input type="text" name="ip_address" value="" id="ip_address" style="max-width:none !important" class="form-control input-xlarge" placeholder="" />
</div> <!-- end input group -->
</div> <!-- end form-group ip_address -->
<!-- login -->
<div class="form-group">
<label for="login">
Login
</label>
<div class="input-group">
<input type="text" name="login" value="" id="login" style="" class="form-control" placeholder="" />
</div> <!-- end input group -->
</div> <!-- end form-group login -->
</div>
</div> <!-- end of row -->
</div> <!-- end of container. -->
</form>
我什至试图通过声明 style="max-width:none !important" 来使 ip_address 字段更宽,但没有用。有什么办法可以让领域更广吗?引导程序中是否有预设宽度?我相信默认值是最大宽度。
这是我的最终输出的样子:
解决方案
当我测试代码时,我没有看到输入的宽度有任何不同。
在 ip_address 字段中,我使用的是 style="max-width:none !important"... 您添加的任何 CSS 都不适用于内联样式 max-width:none; !重要的。
它将覆盖您在 CSS 文件或其他任何地方所做的任何更改。内联样式尤其是 !important 将覆盖任何附加的样式表或类。
我认为问题可能是你的输入有这个style="max-width:none !important"
它覆盖了默认的引导设置,而不是将你的输入设置为最大宽度。
那就是如果您希望它们更宽、更短的包装,<div>
然后<div>
使用 CSS 或“col-sm-6”等..类来操作。
来自 Bootstrap 网站版本 4 的示例。此外,版本 3 也具有“表单控制”类。它使您的表单具有 100% 的宽度,然后您可以通过包装<div>
您选择的或其他合适的元素或 CSS 来操作它。
例子:
<form>
<div class="form-group">
<label for="exampleFormControlInput1">Email address</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Example select</label>
<select class="form-control" id="exampleFormControlSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect2">Example multiple select</label>
<select multiple class="form-control" id="exampleFormControlSelect2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Example textarea</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
</form>
推荐阅读
- python - 如何创建可导出的表格图像?
- python - 将日期列表拆分为连续日期的子集
- node-modules - 为 Vue JS 项目安装 node-sass 时出错
- go - go get 不一致的内部包错误
- c# - 如何在 ASP.NET Core 3.1 中获取服务实例
- scala - Spark Listener在Executors上的onJobComplete上执行钩子?
- c# - MemoryCache 的大小设置是什么意思?
- javascript - 如何删除图例并向 LightningChart js 添加新图例?
- javascript - 如何在打字稿中获取异步函数的返回类型?
- php - PHP fput无法上传文件