Bootstrap 4在IE 11中无法工作。

19

我遇到了一个问题,我的整个网站在IE 11上无法正常工作。我不明白为什么,因为按照官方说法,bootstrap 4应该支持IE 11……

在Firefox、Edge、Chrome和Safari中它都能够很好地工作……

因为现在,我有一种感觉,就是bootstrap 4根本不兼容IE 11……

谢谢任何回复!

这是我的导航栏示例,在IE 11中不可见:

#logonav {

   height: 40px; 
    width: auto;
}

/* change the link color */
.navbar-custom .navbar-nav .nav-link {
    color: #2E8B57;
}
/* change the color of active or hovered links */
.navbar-custom .nav-item .nav-link .active,
.navbar-custom .nav-item:hover .nav-link {
    color: orangered; 
}

/* change the brand and text color */
.navbar-custom .navbar-brand,
.navbar-custom .navbar-text {
    color: #2E8B57;
}

.custom-toggler.navbar-toggler {
    border-color: rgb(46,139,87);
}
.custom-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(46, 139, 87, 1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");

}

<!DOCTYPE html>
<html lang="de">

<head>
    <meta charset="UTF-8">
    <!-- IE Edge Meta Tag -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <!-- Minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ"
        crossorigin="anonymous">
    <link rel="stylesheet" href="ergo.css">
    <title>Bettina Klinkicht Ergotherapeutische Praxis Bonn</title>
    <link rel="shortcut icon" type="image/x-icon" class="img-circle" href="logopur.png">
    <!-- Global Site Tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-107069424-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() { dataLayer.push(arguments) };
        gtag('js', new Date());

        gtag('config', 'UA-107069424-1');
    </script>
</head>
<body>
 <nav class="navbar navbar-inverse fixed-top transparent navbar-toggleable-sm navbar-custom">
        <div class="navbar-inner">
            <!-- Brand and toggle grouped for better mobile display -->
            <button class="navbar-toggler navbar-toggler-right custom-toggler" type="button" data-toggle="collapse" data-target="#navmobile"
                aria-controls="navmobile" aria-expanded="false" aria-label="Toggle Navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

            <a href="home.html" class="navbar-brand"><img src="logopur_neu.png" alt="Logo" id="logonav"></a>
        </div>
        <!-- Collect nav-links for toggling-->
        <div class="collapse navbar-collapse" id="navmobile">
            <div class="navbar-nav ml-auto">
                <a class="nav-item nav-link active" href="#">Home</a>
                <a class="nav-item nav-link" href="Therapeutin.html">Über mich</a>

                <div class="dropdown">
                    <a class="nav-item nav-link dropdown-toggle" href="#" data-toggle="dropdown" id="servicesDropdown" aria-haspopup="true" aria-expanded="false">Angebot</a>
                    <div class="dropdown-menu" aria-labelledby="servicesDropdown">
                        <a class="dropdown-item" href="Geriatrie.html">Geriatrie</a>
                        <a class="dropdown-item" href="Neurologie.html">Neurologie</a>
                        <a class="dropdown-item" href="Spiegeltherapie.html">Spiegeltherapie</a>
                        <a class="dropdown-item" href="Schwindeltherapie.html">Schwindeltherapie</a>
                        <a class="dropdown-item" href="Biographiearbeit.html">Biographiearbeit</a>
                        <a class="dropdown-item" href="Brain_Gym.html">Brain Gym</a>
                        <a class="dropdown-item" href="Sensibilitaetstraining.html">Sensibilitätstraining</a>
                        <a class="dropdown-item" href="Gleichgewichtstraining.html">Gleichgewichtstraining</a>
                    </div>
                </div>

                <a class="nav-item nav-link" href="Kontakt.html">Kontakt</a>
            </div>
        </div>
        </div>
        </div>
    </nav>
        <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"
        crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn"
        crossorigin="anonymous"></script>
    <script src="ergo.js"></script>
</body>
</html>

在我的IE11中可以工作,也许尝试按下Ctrl + F5? - TidyDev
你有查看过F12开发者工具中的错误吗?我查看了一下,发现它在抱怨Jquery 3.2.1 slim版本。我将'slim'版本替换为完整版本。虽然这不是唯一需要做的事情(与Angular polyfill相关),但这可能会有所帮助。 - Bob Tabor
5个回答

42

发布此帖,以防能帮助到其他人。我碰到了同样的问题,Chrome中一切正常,但在IE11中似乎无法看到任何CSS。我看到了这篇帖子,但没有帮助。经过更多搜索,我发现建议在HEAD标签中添加以下内容,并且它起作用了。想到会在谷歌搜索中首先出现其中之一,因此在此发布。

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

3
确认一下就解决了。我在一个新的Bootstrap 4网站上进行了大量开发,然后在IE11中测试,但显示效果很差。这个meta标签立即解决了这个问题。 - Klom Dark
看到旧文档中提到需要这个标签,当我想知道Bootstrap 4是否仍然需要这行代码时,就来到了这里... - Bytech
确认!这个方法起作用了,而且还解决了我的VueJs问题! - Andrej Gaspar
哎呀!谢谢啊!我们公司的电脑在IE11中设置了一个策略,以“兼容模式”渲染所有内部网页。我完全忘记了…… - mmcfly
更多信息:https://dev59.com/8mw15IYBdhLWcg3wMY2L - Mladen B.

4
在IE浏览器中,高度和宽度需要明确设置,否则会出现问题。 因此,width: auto可能会导致问题。auto给我带来了很多问题。也许可以尝试将其改为其他值。

3

当使用类.card-deck时,我在IE11中遇到了显示问题。我通过添加以下内容来解决这个问题:

.card-deck {
    width: 100% !important;
}

这很有帮助。谢谢你。目前遇到了关于卡片的问题 - 你的解决方案已经修复了 - 现在我正在研究一些边距和填充的问题。 - dogonaroof

0

align-self-center 类帮助我解决了在ie11中的问题。


0
我曾经遇到过同样的问题。你需要在头部关闭所有的meta和link标签,加上“/”符号。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接