【问题标题】:Bootstrap datetimepicker appears at the top-left corner of the windowBootstrap datetimepicker 出现在窗口的左上角
【发布时间】:2016-01-13 11:48:59
【问题描述】:

我正在使用天知道在哪里的日期时间选择器,但它恰好位于一组文件中,命名约定为 bootstrap-datetimepicker-min.js.css。我假设这是引导小部件之一,那么,我应该认为它基于 jQuery UI 的日期时间选择器。无论如何,API 与 jQuery UI 日期时间选择器非常相似。

所以,我有这个代码,但是一旦我点击日期输入字段,日期时间选择器就会显示在窗口的左上角,然后它也不会消失。

ThePage.cshtml

...

<!-- stuff -->

<div class="form-group">
            @Html.LabelFor(model => model.FromDate, htmlAttributes: new { @class = "control-label col-md-2"})
            <div class="col-md-10">
                <input type="text"class="form-control" id="dtFromDate" name="FromDate" />
                @Html.ValidationMessageFor(model => model.FromDate, "", new { @class = "text-danger" })
            </div>
        </div>

@section scripts {
    <script type="text/javascript">
        $(document).ready(Initialize);

        function Initialize()
        {
            $('#dtFromDate').datetimepicker();
            $('#dtToDate').datetimepicker();
        }
    </script>
}

并且布局页面具有包含正确的 JavaScript 和 CSS 文件的 include 语句:

Layout.cshtml

<!-- on the top of the page somewhere -->
@Styles.Render("~/Content/css")

...
<!-- stuff -->

<!-- at the bottom of the layout page -->
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/components")
@RenderSection("scripts", required: false)

BundleConfig.cs

bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/site.css",
                      "~/Content/Calendar/css/bootstrap-datetimepicker.min.css",
                      "~/Content/select2/css/select2.min.css"
                      ));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/respond.js"
                      ));

bundles.Add(new ScriptBundle("~/bundles/components").Include(
                "~/Content/Calendar/js/bootstrap-datetimepicker.min.js",
                      "~/Content/select2/js/select2.full.min.js",
                      "~/Content/select2/js/i18n/en.js"
                ));

【问题讨论】:

标签: jquery css asp.net-mvc twitter-bootstrap


【解决方案1】:

这显然不理想,但这是一个适用于 CSS 的快速修复

span.select2-container[style='position: absolute; top: 0px; left: 0px;'] {
    display: none;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    • 2016-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    相关资源
    最近更新 更多