我在我的应用中使用Bootstrap 3 navbar
:
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"><span>
</button>
<a class="navbar-brand" href="#">mapERP</a>
</div>
<div class="collapse navbar-collapse navbar-pills" id="navbarCollapse">
<div class="col-md-3 col-sm-3 pull-left">
<form class="navbar-form" role="search" id="search-form">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="geo-search" id="geo-search">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
<ul class="nav navbar-nav navbar-right clearfix">
<li><p class="navbar-text" id="userName"style="display:none;"></a></li>
<li><img class="img-responsive img-circle" id="userImg" src="" style="display:none;"></li>
<li><a href="#" class="btn btn-default" id="authorize-button">Login</a></li>
</ul>
</div>
</div>
</nav>
我正在使用IE的这个条件评论:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if IE]>
<script type="text/javascript">
alert("Inside conditional comment");
window.isIE=true;
</script>
<script type="text/javascript" src="http://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script type="text/javascript" src="scripts/lib/respond.min.js"></script>
<script type="text/javascript" src="scripts/lib/json2.js"></script>
<script type="text/javascript" src="scripts/lib/Object.keys-polyfill.js"></script>
<![endif]-->
我发现respond.min.js
按照其他答案的建议加载,但navbar-toggle
仍然显示,所有navbar-nav
项目都超大。
Screenshot of the way it should look in desktop mode
Screenshot of the way it IE8 renders it
正如评论中所建议的那样,我已经使用相对路径下载并添加respond.min.js
到页面,这个html是从IE8复制的:
<SCRIPT src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></SCRIPT>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --><!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<SCRIPT type=text/javascript>
alert("Inside conditional comment");
window.isIE=true;
</SCRIPT>
<SCRIPT type=text/javascript src="http://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js">
</SCRIPT>
<SCRIPT type=text/javascript src="scripts/lib/respond.min.js"></SCRIPT>
<SCRIPT type=text/javascript src="scripts/lib/json2.js"></SCRIPT>
<SCRIPT type=text/javascript src="scripts/lib/Object.keys-polyfill.js"></SCRIPT>
<LINK rel=stylesheet href="css/bootstrap.min.css">