简体   繁体   English

Bootstrap 4 .form-inline 在 Internet Explorer 11 中不起作用

[英]Bootstrap 4 .form-inline not working in Internet Explorer 11

I have a form in an application using Bootstrap 4. It renders as I want it to in all browsers, except Internet Explorer 11.我在使用 Bootstrap 4 的应用程序中有一个表单。它在除 Internet Explorer 11 之外的所有浏览器中都按照我想要的方式呈现。

I have used Bootstrap's .form-inline class because according to the docs我使用了 Bootstrap 的.form-inline类,因为根据文档

Use the .form-inline class to display a series of labels, form controls, and buttons on a single horizontal row.使用.form-inline类在单个水平行上显示一系列标签、表单控件和按钮。

The correct rendering of the form looks like this .表单的正确呈现如下所示 The screenshot below was taken from Chrome v80:下面的截图来自 Chrome v80:

在此处输入图片说明

In Internet Explorer 11 it renders as follows.在 Internet Explorer 11 中,它呈现如下。

在此处输入图片说明

The markup is as follows.标记如下。

<div class="row">
    <form method="get" class="form-inline" action="#"> 

        <div class="col">   
            <label for="date_start" class="mr-2 float-left">From</label>
            <div class="input-group date mr-5" id="dateStart" data-target-input="nearest">
                <div class="input-group-append" data-target="#dateStart" data-toggle="datetimepicker">
                    <div class="input-group-text"><i class="fa fa-calendar" aria-hidden="true"></i></div>
                </div>
                <input type="text" name="dateStart" value="2020-03-17" class="form-control datetimepicker-input" data-target="#dateStart" autocomplete="off">  
            </div>
        </div>

        <div class="col">
            <label for="date_end" class="mr-2 float-left">To</label>
            <div class="input-group date mr-5" id="dateEnd" data-target-input="nearest">
                <div class="input-group-append" data-target="#dateEnd" data-toggle="datetimepicker">
                    <div class="input-group-text"><i class="fa fa-calendar" aria-hidden="true"></i></div>
                </div>
                <input type="text" name="dateEnd" value="2020-03-24" class="form-control datetimepicker-input" data-target="#dateEnd" autocomplete="off">  
            </div>
        </div>

        <button class="btn btn-primary btn-md-top-pad">View Notifications <i class="fas fa-chevron-right" aria-hidden="true"></i></button>

    </form>
</div>

If I remove the .form-inline in Internet Explorer 11 using Developer Tools the layout is more usable but still broken.如果我使用开发人员工具在 Internet Explorer 11 中删除.form-inline布局更有用,但仍然损坏。

在此处输入图片说明

I read inline-flex input element breaks to new line in IE11 and tried swapping my .row with a .container .在 IE11 中读取inline-flex 输入元素中断到新行并尝试将我的.row.container交换。 This seems to help but it centres the form and therefore doesn't look as I want in other (non IE 11) browsers.这似乎有帮助,但它使表单居中,因此在其他(非 IE 11)浏览器中看起来不像我想要的那样。 It also makes the input fields look much longer than desired.它还使input字段看起来比预期长得多。

在此处输入图片说明

Surely it is possible to left align the form and have it all on one line?当然可以左对齐表单并将其全部放在一行上吗?

What is the problem with this and how can I fix it for IE 11 in a way that won't break it for other browsers?这有什么问题,我如何才能以不会破坏其他浏览器的方式为 IE 11 修复它? I want to render it as per the first screenshot, consistently in all browsers.我想按照第一个屏幕截图在所有浏览器中一致地呈现它。

I compared with the official demo which can work well in IE 11, it seems that the issue is with <div class="col"> .我与可以在 IE 11 中正常运行的官方演示进行了比较,似乎问题出在<div class="col"> The elements in the form are not wrapped by div .col in the official demo.表格中的元素在官方demo中没有用div .col包裹。 I removed them and it can work well in IE 11 and other browsers.我删除了它们,它可以在 IE 11 和其他浏览器中正常运行。

Online demo在线演示

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" /> <form method="get" class="form-inline" action="#"> <label for="date_start" class="mr-2 float-left">From</label> <div class="input-group date mr-5" id="dateStart" data-target-input="nearest"> <div class="input-group-append" data-target="#dateStart" data-toggle="datetimepicker"> <div class="input-group-text"><i class="fa fa-calendar" aria-hidden="true"></i></div> </div> <input type="text" name="dateStart" value="2020-03-17" class="form-control datetimepicker-input" data-target="#dateStart" autocomplete="off"> </div> <label for="date_end" class="mr-2 float-left">To</label> <div class="input-group date mr-5" id="dateEnd" data-target-input="nearest"> <div class="input-group-append" data-target="#dateEnd" data-toggle="datetimepicker"> <div class="input-group-text"><i class="fa fa-calendar" aria-hidden="true"></i></div> </div> <input type="text" name="dateEnd" value="2020-03-24" class="form-control datetimepicker-input" data-target="#dateEnd" autocomplete="off"> </div> <button class="btn btn-primary btn-md-top-pad">View Notifications <i class="fas fa-chevron-right" aria-hidden="true"></i></button> </form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM