How do I fix twitter-bootstrap on IE?
Asked Answered
J

13

40

The navbar doesn't seem to be working properly in IE. Here's a screenshot of it in IE.

screenshot

I've been looking through many bootstrap-topics on stackoverflow.com, but the "help" they give people doesn't work for me.

After body tag:

<div class="container">
    <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    <a class="brand" href="?id=home">OnniServer.tk</a>
                    <div class="nav-collapse">
                    <ul class="nav">
                    <li <?php if ((isset($_GET['id'])) && ($_GET['id'] == home)) { echo "class='active'"; } ?>><a href="?id=home">Home</a></li>
                    <li <?php if ((isset($_GET['id'])) && ($_GET['id'] == donate)) { echo "class='active'"; } ?>><a href="?id=donate">Donate</a></li>
                    <li <?php if ((isset($_GET['id'])) && ($_GET['id'] == about)) { echo "class='active'"; } ?>><a href="?id=about">About</a></li>
                    <li <?php if ((isset($_GET['id'])) && ($_GET['id'] == staff)) { echo "class='active'"; } ?>><a href="?id=staff">Staff</a></li>
                    <li <?php if ((isset($_GET['id'])) && ($_GET['id'] == vote)) { echo "class='active'"; } ?>><a href="?id=vote">Vote</a></li>
                    <li class="dropdown">
                        <a href="" class="dropdown-toggle" data-toggle="dropdown">Play now: <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="minecraft">In browser</a></li>
                                <li><a href="http://minecraft.net">Buy it now</a></li>
                                <li><a href="#">No link for crack</a></li>
                            </ul>
                    </li>
                    <li class="dropdown">
                        <a href="" class="dropdown-toggle" data-toggle="dropdown">Perms for: <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="?id=citizen">Citizen(s)</a></li>
                                <li><a href="?id=vip">VIP(s)</a></li>
                                <li><a href="?id=vipplus">VIP+(s)</a></li>
                                <li><a href="?id=modjr">Jr. Moderator(s)</a></li>
                                <li><a href="?id=mod">Moderator(s)</a></li>
                                <li><a href="?id=admin">Admin(s)</a></li>
                                <li><a href="?id=owner">Owner</a></li>
                            </ul>
                    </li>
                    <li class="dropdown">
                        <a href="" class="dropdown-toggle" data-toggle="dropdown">Mail to: <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="mailto:[email protected]">Onni (server Owner)</a></li>
                            </ul>
                    </li>
                    <script>
                        $('.dropdown-toggle').dropdown()
                    </script>
                    </ul>
                    </div>
                </div>
            </div>
    </div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div class="hero-unit">
        <style "text/css">
        </style>
        <?php
        if (((isset($_GET['id'])) &&($_GET['id'] == home)) || (!isset($_GET['id']))) { include('home.php'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == donate)) { include('donate.php'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == about)) { include('about.php'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == staff)) { include('staff.php'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == vote)) { include('vote.php'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == citizen)) { include('permissions/citizen.html'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == vip)) { include('permissions/vip.html'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == vipplus)) { include('permissions/vipplus.html'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == modjr)) { include('permissions/modjr.html'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == mod)) { include('permissions/mod.html'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == admin)) { include('permissions/admin.html'); };
        if ((isset($_GET['id'])) && ($_GET['id'] == owner)) { include('permissions/owner.html'); };
        ?>
    </div>
</div>
Jaguar answered 25/6, 2012 at 0:19 Comment(3)
Have you tried the guidance in this question ? #9780964Spinescent
Look at Facuu7's answer. Make sure the first line of your html page is <!DOCTYPE HTML>Sort
@OnniBucht please accept the answer below it appears to be what you was looking for.Ay
I
65

You need to put <!DOCTYPE HTML> in the first line of your html.

Ir answered 12/9, 2012 at 18:53 Comment(6)
This works. I had an html comment as the first line, and bootstrap was broken. I deleted it, and now it works great. Thanks!Sort
Yes i can confirm, adding <!DOCTYPE HTML> works. I had it missing and after adding DOCTYPE it worked fine.Microampere
I already put <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">Jaguar
@OnniBucht: it's not the same string, <!DOCTYPE html> stands for html5Suffolk
I recommend further readings about the important of the DTD declaration w3.org/QA/Tips/Doctype and their relation to the browsers processing the HTML content.Manado
I am using bootstrap 3. It did not fix mine. When I do view source, it is showing as the first thing on the page.Valenza
G
51

You can add the meta tag:

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

A brief explanation on what it is and how it works is found on this link.

Gab answered 5/6, 2013 at 14:15 Comment(2)
This did the trick for me. When I monitored things with the developer tools I noticed it was reporting to run in compatibility mode while deployed on the "intranet" but not on my development machine.Tetrahedron
This worked for me, but now the menus are broken using Bootstrap 3. This at least is one step closer (the <!DOCTYPE html> didn't work for me.)Destine
I
19

Just for completeness - it's worth noting that with Bootstrap 3, as per the docs, ensure the following structure in your page. It solved issues I was having with IE9 and v3.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- content -->
</body>
</html>
Intracardiac answered 25/6, 2014 at 23:59 Comment(0)
C
6

Not sure if it will fix your particular issue but worth sharing anyway.

I had issues with twitter boot strap in IE. No rounded corners. Navigation menu not collapsing. Spans not sitting in correct location, even some images not displaying.

Strangely, site works okay in IE when run through visual studio debugger, its once deployed to a server that the problem occurs.

Try using IE developer tools (F12 is keyboard shortcut) Check your browser mode and document mode. (its at the top along side the menu bar)

Problem happened for me as document was IE7 and browser was IE10 compatibility. I added a http header in IIS: Name X-UA-Compatible Value IE=EmulateIE9

Now the page loads as document - IE9 standards, browser IE10 compatibility and all the previous issues are resolved.

Hope this helps.

-tessi

Christianson answered 13/2, 2013 at 1:52 Comment(1)
This is not an answer.Ay
A
6

Need to include these two scripts for IE

<script src="http://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="http://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
Antiworld answered 21/12, 2014 at 4:54 Comment(2)
Bhai Kadak! It Works!! Great!Also
I tought this is only for older than IE9, so for IE8 and IE7Enfilade
A
4

If you are within the intranet and the settings are set to compatibility mode, then proper doctypes and respond.js is not enough.

Please refer to this link for more info: Force IE8 or IE9 document mode to standards and see Ralph Bacon's answer.

It would be same as this:

<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Achelous answered 14/7, 2015 at 7:12 Comment(0)
D
3

I had the same problem and none of the other answers worked. My problem was a weird one where IE9 wasn't able to connect to any https sites, therefore since I was using the online maxcdn bootstrap files like,

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css

none of that css and js was being applied. Going into the Advanced tab of Internet Explorer options I verified that not having "use TLS 1.0" checked caused the problem with https sites and files, and once checked my bootstrap page was formatted as expected.

As others have noted use the proper doctype below (maybe a valid html4 doctype will work, but if you're starting anew might as well use html5.)

The respond js and html5 shim (if using that) are for IE8. IE9 doesn't need that. The code below uses the standard method of targeting ie8 and below.

--Art

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<!-- content -->
</body>
</html>
Depside answered 26/3, 2015 at 5:14 Comment(2)
here you are the last answer and after hours, your solution is what helped me. Not sure when that box was unchecked or if I did it or just crappy IE, but that was it. much thanks!!Axenic
Same thing. I enabled TLS 1, and said "Ok" to an IE 9 security certificate warning. Previously, all Bootstrap dropdowns were unresponsive. This made them work in both IE8 and IE9.Melonymelos
F
3

I had this problem recently. I made these settings change. And it worked for me. !

verify these settings

Foushee answered 11/6, 2015 at 23:11 Comment(0)
C
2

Internet Explorer has a maximum number of code lines for style sheet recognition.

This is Bootstrap navbar style rule that set the float property for navbar items:

.navbar-nav > li {
    float: left;
}

That rule in Bootstrap 3 (probably in early versions too) is on line 5247.

As it says here: Internet Explorer's CSS rules limits, a sheet may contain up to 4095 lines.

Costplus answered 23/10, 2013 at 14:57 Comment(0)
S
1

I had similar problems as well. I put the following line of code in the head of my layout file and all seems to be fine.

<meta http-equiv="X-UA-Compatible" content="IE=9">
Swick answered 18/10, 2013 at 14:8 Comment(0)
F
1

I was having a similar issue. In my case, looking at the CSS i found a position: initial.

After some research, i found that mobile IE browser doesn't supports it.

I simply put a position: relative instead and everything worked fine.

Flyman answered 28/8, 2015 at 4:42 Comment(0)
C
0

If you are using responsive layout, try including this js on your code: https://github.com/scottjehl/Respond

Cheyenne answered 18/4, 2013 at 12:15 Comment(0)
I
-1

Please put the pages in localhost and try

Inflexed answered 6/5, 2018 at 7:13 Comment(1)
most probably he is loading from desktop. CSS will ignored due to mime type mismatch.Inflexed

© 2022 - 2024 — McMap. All rights reserved.