Bootstrap导航标签无法正常工作

时间:2016-02-27 14:25:10

标签: jquery html twitter-bootstrap

我的导航标签不起作用,但我检查了代码,如1000 thimes。 div col标签之间还有其他代码,但这不应该有任何区别。

        <ul class="nav nav-tabs" role="tablist" data-tabs="tabs">
            <li class="active"><a href="#coursera" data-toggle="tab">Coursera</a></li>
            <li><a href="#research" data-toggle="tab">Research</a></li>
            <li><a href="#blog" data-toggle="tab">Blog</a></li>
        </ul>

        <div class="tab-content">

            <div class="tab-pane fade in active" id="coursera">
                <div class="col-sm-10"></div>
                <div class="col-sm-2"></div>
            </div>

            <div class="tab-pane fade" id="research">
                <div class="col-sm-10"></div>
                <div class="col-sm-2"></div>
            </div>

            <div class="tab-pane fade" id="blog">
                <div class="col-sm-10"></div>
                <div class="col-sm-2"></div>
            </div>
        </div>

2 个答案:

答案 0 :(得分:0)

<!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.6/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
        <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    </head>
    <body>        
        <div class="container">
            <h3>Tabs With Dropdown Menu</h3>
            <ul class="nav nav-tabs" role="tablist" data-tabs="tabs">
                <li class="active"><a href="#coursera" data-toggle="tab">Coursera</a></li>
                <li><a href="#research" data-toggle="tab">Research</a></li>
                <li><a href="#blog" data-toggle="tab">Blog</a></li>
            </ul>            
            <div class="tab-content">                
                <div class="tab-pane fade in active" id="coursera">
                    <div class="col-sm-10"> coursera tab Div with class col-sm-10</div>
                    <div class="col-sm-2">coursera tab Div with class col-sm-2</div>
                </div>

                <div class="tab-pane fade" id="research">
                    <div class="col-sm-10"> research tab Div with class col-sm-10</div>
                    <div class="col-sm-2">research tab Div with class col-sm-2</div>
                </div>

                <div class="tab-pane fade" id="blog">
                    <div class="col-sm-10"> blog tab Div with class col-sm-10</div>
                    <div class="col-sm-2">blog tab Div with class col-sm-2</div>
                </div>
            </div>
        </div>        
    </body>
</html>

答案 1 :(得分:0)

感谢您的回答!我终于找到了原因......

显然标签下方的标题是问题所在。我的自定义css中的标题有填充顶部:100px和margin-top:-100px。每当我删除它们时,标签都在工作。我想我应该找到另一种设置锚点的方法。