使用IP地址时,Twitter Bootstrap不起作用但在“localhost”中工作

时间:2015-10-15 04:10:20

标签: html css twitter-bootstrap twitter localhost

我需要您在学习Twitter Bootstrap时面临的问题的帮助和建议。我正在使用W3Schools中的确切代码来建立可折叠的NavBar。

我正在使用Eclipse和Apache Tomcat本地服务器。

我看到两个不同的输出具有相同的代码。

由于一些奇怪的原因,我无法上传图片.. :(

在“localhost”(http://localhost:8080/test.html)上运行的网站

在“IP地址”(http://my-ip:8080/test.html

上运行时的网站
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Case</title>   
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse"
                    data-target="#myNavbar">
                    <span class="icon-bar"></span> <span class="icon-bar"></span> <span
                        class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">WebSiteName</a>
            </div>
            <div class="collapse navbar-collapse" id="myNavbar">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li class="dropdown"><a class="dropdown-toggle"
                        data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Page 1-1</a></li>
                            <li><a href="#">Page 1-2</a></li>
                            <li><a href="#">Page 1-3</a></li>
                        </ul></li>
                    <li><a href="#">Page 2</a></li>
                    <li><a href="#">Page 3</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#"><span class="glyphicon glyphicon-user"></span>
                            Sign Up</a></li>
                    <li><a href="#"><span class="glyphicon glyphicon-log-in"></span>
                            Login</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container">
        <h3>Collapsible Navbar</h3>
        <p>In this example, the navigation bar is hidden on small screens
            and replaced by a button in the top right corner (try to re-size this
            window).
        <p>Only when the button is clicked, the navigation bar will be
            displayed.</p>
    </div>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

X-UA兼容性解决了这个问题。

有人可以确认这是否是我的问题的正确解决方案或只是临时修复?

X-UA-Compatible” content=“IE=9; IE=8; IE=7; IE=EDGE