Bootstrap 3.3.5 - navbar-toggle按钮无法在iphone上运行

时间:2015-06-21 19:36:59

标签: javascript jquery html css twitter-bootstrap

我正在使用自举网站,并且在我的iphone和ipad上查看时出现导航栏切换问题。下拉按钮可见,但不响应或扩展。似乎在我所有的计算机浏览器中都运行良好。

我正在使用bootstrap v3.3.5和jquery-1.11.3

<head>

    <!-- Website Title & Description for Search Engine purposes -->
    <title></title>
    <meta name="description" content="">

    <!-- Mobile viewport optimized -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <!-- Bootstrap CSS -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="bootstrap/fonts/bootstrap-glyphicons.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="includes/css/styles.css" rel="stylesheet">
    <link href="includes/css/fonts.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600|Arvo' rel='stylesheet' type='text/css'>

    <!-- Include Modernizr in the head, before any other Javascript -->
    <script src="includes/js/modernizr-2.6.2.min.js"></script>

</head> 

这是我的导航栏

<!--Navbar-->
<div class="navbar" role="navigation">
    <div class="container">

        <!--navbar responsive toggle-->
        <div class="navbar-header">
            <button class="navbar-toggle collapsed" type="button" data-target="#navbar-responsive-collapse" data-toggle="collapse" >
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <!-- brand and toggle grouped together for better mobile display -->
            <img class="navbar-brand" src="images/navbar_logo.png" alt="logo">
        </div><!--end of navbar-header-->

        <div class="collapse navbar-collapse" id="navbar-responsive-collapse">
            <ul class="nav navbar-nav navbar-default" id="myNav">
                <li class="active">
                    <a href="index.html"> Home</a>
                </li>
                <li>
                    <a href="services.html"> Services</a>
                </li>
                <li>
                    <a href="contact.html"> Contact</a>
                </li>
            </ul>
        </div><!-- end of collapse-->
    </div><!-- end of container-->
</div><!-- end of navbar -->

底部链接。

<!-- All Javascript at the bottom of the page for faster page loading -->

<!-- First try for the online version of jQuery-->
<script src="http://code.jquery.com/jquery.js"></script>

<!-- If no online access, fallback to our hardcoded version of jQuery -->
<script>window.jQuery || document.write('<script src="includes/js/jquery-1.11.3.min.js"><\/script>')</script>

<!-- Bootstrap JS -->
<script src="bootstrap/js/bootstrap.min.js"></script>
如果你想看到css:https://jsfiddle.net/Dinkledine/asLLydyz/8/

,这里有一个js.fiddle

我看过类似的帖子,这些是我收集的解决方法。到目前为止,他们都没有工作过。所以我开始认为它是我的标记。

我尝试过: 将bootstrap从v3.3.4更新到v3.3.5 ..... 将jquery从1.8.2更新为1.11.3 ..... 在bootstrap.min.css中将“ontouchstart”替换为“disable-ontouchstart”

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

Bootstrap v2 Dropdown Navigation not working on Mobile Browsers

iPhone上的Safari仅支持<a><input>元素的点击事件。

你可以在这里找到你的修复。

答案 1 :(得分:0)

<button class="collapse navbar-collapse" id="navbar-responsive-collapse">
        <ul class="nav navbar-nav navbar-default" id="myNav">
            <li class="active">
                <a href="index.html"> Home</a>
            </li>
            <li>
                <a href="services.html"> Services</a>
            </li>
            <li>
                <a href="contact.html"> Contact</a>
            </li>
        </ul>
    </div>

在CSS中:

body{z-index:-1}