如何在Max width上增加Bootstrap容器的宽度?

Bri*_*n J 5 html css containers contentsize twitter-bootstrap

我在一个类型容器的Bootstrap div中放置了一个DataTable.当我在浏览器的最大宽度上运行网站时,表格的容器会添加滚动条并切断表格中的最后一列.

我确实尝试使用这里container-fluid建议的div类型,但这进一步减少了表容器的宽度.

在检查元素时,似乎container body-content在布局页面周围继承的表单是在表容器的左侧和右侧添加边距:

在此输入图像描述

一个可能的解决方案我正在考虑是否要减少继承container body-content最大宽度的余量,但我不知道如何通过CSS做到这一点.

从下面的屏幕截图中可以看到删除col被切断,尽管表中有足够的空白要扩展:

在此输入图像描述

题:

如何在Max width上增加Bootstrap容器的宽度?

表容器标记的要点:

<div class="container">


    <div class="form-group">
        <div class="table-responsive">
            <div class="table-responsive" id="datatable-wrapper">

                <table id="escalation" class="table table-striped table-bordered" cellspacing="0">
                    <thead>
                        <tr>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">ID</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Application</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">UID</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Type</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Status</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Statement</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Created</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Updated</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Last Update</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Next Update</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Root Cause</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Details</th>
                            <th style="font-size: 12px; border-right: 1px solid #7591ac; ">Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (HP.ESCALATION.Web.Models.Escalation item in Model)
                        {

                            <tr>
                                <td>@item.ID</td>
                                <td>@item.Application</td>
                                <td class="td-limit">@item.EM</td>
                                <td class="td-limit">@item.Event</td>
                                <td class="td-limit">@item.status</td>
                                <td class="td-limit">@item.Statement</td>
                                <td class="td-limit">@item.Created</td>
                                <td class="td-limit">@item.Updated</td>
                                <td data-order="@item.UnixTimeStamp" class="td-limit">@item.UpdatedTime</td>
                                <td class="td-limit">@item.NextUpdate</td>
                                <td class="td-limit">@item.RootCause</td>
                                @* Add CRUD buttons to each table row --> *@
                                <td><button type="submit" style="background-color: #0CA281;" class="btn btn-success details">Details</button></td>
                                <td><button type="submit" class="btn btn-danger delete">Delete</button></td>
                            </tr>

                        }


                    </tbody>
                </table>




            </div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

布局容器的要点:

<div class="container body-content" style="margin-top: 90px; margin-bottom: 70px;">

                @* Main Content Render *@
                <div id="content">
                    <div class="content-wrapper main-content clear-fix">

                    </div>
                    @RenderSection("featured", required: false)
                    <section class="content-wrapper main-content clear-fix">
                        @RenderBody()
                    </section>
                </div>


            </div>  
Run Code Online (Sandbox Code Playgroud)

Kei*_*sud 12

上面的答案都不是好的解决方案。您可以通过创建新的_project_variables.scss并在引导前将其导入主scss文件中来轻松更改引导程序的变量。例如:

// Grid containers
//
// Define the maximum width of `.container` for different screen sizes.

$container-max-widths: (
        sm: 540px,
        md: 720px,
        lg: 960px,
        xl: 1280px
) !default;
Run Code Online (Sandbox Code Playgroud)

  • 应该标记为最佳答案。 (3认同)
  • 我很高兴@SteveBauman。如果您不知道,也可以向数组添加更多大小。由于高分辨率27英寸Mac,我最近开始这样做。我添加xxl:1960px等。您还需要向$ grid-breakpoints数组添加值。 (2认同)

Kei*_*ski 8

在 Bootstrap 4 中使用:

@media only screen and (min-width : 1200px) {
    .container { max-width: 1500px; }
}
Run Code Online (Sandbox Code Playgroud)


Bri*_*n J 6

在这种情况下工作但仍然允许容器在较小分辨率上调整大小的解决方案是使用@media定位CSS:

@media only screen and (min-width : 1200px) {

    .container { width: 1500px; } 

}
Run Code Online (Sandbox Code Playgroud)

  • 虽然这是一个可以接受的答案,但正确的答案是用 Sass 更改这些值(检查@Keith Mifsud 答案) (2认同)

il0*_*d0g 6

我也需要使用超大屏幕来工作,所以我在下面添加了。

/* large devices */
@media (min-width: 1200px) {
  .container {
     max-width: 1200px;
   }
}
/* extra large devices */
@media screen and (min-width: 1800px) {
  .container {
    max-width: 1800px;
  }
}
Run Code Online (Sandbox Code Playgroud)