所以我有一个简单的形式,我一直在搞乱:
libsvm
这是一个Symfony 3 Twig模板,它看起来像这样:
正如您所看到的,输入只是略长于其他元素,即使所有内容都在<div class="container">
<form name="form" method="post">
<div class="form-row mt-5">
<div class="col-3">
<label class="sr-only form-control-label required" for="form_column_name">Column Name</label>
<select id="form_column_name" name="form[column_name]" class="form-control-lg form-control"><option value="Field 1" selected="selected">Field 1</option><option value="Field 2">Field 2</option></select>
</div>
<div class="col-8">
<label class="sr-only form-control-label required" for="form_column_value">Column Value</label>
<input type="text" id="form_column_value" name="form[column_value]" required="required" class="form-control-lg form-control" placeholder="Query" />
</div>
<div class="col-1">
<button class="btn btn-primary btn-lg" type="button">Search</button>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<div class="progress" style="height: 25px;">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<table class="table" width="101%">
<thead class="thead-light">
<tr>
<th scope="col">#</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Username</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<input type="hidden" id="form__token" name="form[_token]" value="n0n-XzlZGwNC4-GUi8PiM5UYC25lSx_vMg7qwI7OPSg" />
</form>
</div>
。
有谁知道如何解决这个问题?我可以将进度条设置为col-12
,但我无法弄清楚如何更改表格。它也感觉有点hacky,所以我想知道是否有更好的解决方案。
此外,使用width: 101%
会导致尺寸差异发生变化:
所以我假设我设置了container-fluid
错误。我已经尝试过使用form
,但无法获得边距,也无法以这种方式工作。
答案 0 :(得分:1)
看起来您需要重置按钮上的填充并为其指定宽度:
<button class="btn btn-primary btn-lg pr-0 pl-0 w-100" type="button">Search</button>
下面的演示在整页播放
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<form name="form" method="post" >
<div class="form-row mt-5">
<div class="col-3">
<label class="sr-only form-control-label required" for="form_column_name">Column Name</label>
<select id="form_column_name" name="form[column_name]" class="form-control-lg form-control"><option value="Field 1" selected="selected">Field 1</option><option value="Field 2">Field 2</option></select>
</div>
<div class="col-8">
<label class="sr-only form-control-label required" for="form_column_value">Column Value</label>
<input type="text" id="form_column_value" name="form[column_value]" required="required" class="form-control-lg form-control" placeholder="Query" />
</div>
<div class="col-1" style="flex-shrink:1">
<button class="btn btn-primary btn-lg pr-0 pl-0 w-100" type="button">Search</button>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<div class="progress" style="height: 25px;">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<table class="table" width="101%">
<thead class="thead-light">
<tr>
<th scope="col">#</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Username</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<input type="hidden" id="form__token" name="form[_token]" value="n0n-XzlZGwNC4-GUi8PiM5UYC25lSx_vMg7qwI7OPSg" />
</form>
</div>
您还可以添加自适应类,以便为按钮文本留出空间:
<div class="col-lg-8 col-sm-7">
<div class="col-lg-1 col-sm-2">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<form name="form" method="post" class="m-0">
<div class="form-row mt-5">
<div class="col-3">
<label class="sr-only form-control-label required" for="form_column_name">Column Name</label>
<select id="form_column_name" name="form[column_name]" class="form-control-lg form-control"><option value="Field 1" selected="selected">Field 1</option><option value="Field 2">Field 2</option></select>
</div>
<div class="col-lg-8 col-sm-7">
<label class="sr-only form-control-label required" for="form_column_value">Column Value</label>
<input type="text" id="form_column_value" name="form[column_value]" required="required" class="form-control-lg form-control" placeholder="Query" />
</div>
<div class="col-lg-1 col-sm-2" style="flex-shrink:1">
<button class="btn btn-primary btn-lg pr-0 pl-0 w-100" type="button">Search</button>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<div class="progress" style="height: 25px;">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-12">
<table class="table" width="101%">
<thead class="thead-light">
<tr>
<th scope="col">#</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Username</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<input type="hidden" id="form__token" name="form[_token]" value="n0n-XzlZGwNC4-GUi8PiM5UYC25lSx_vMg7qwI7OPSg" />
</form>
</div>