Scollspy和附加在bootstrap上

时间:2016-07-06 18:12:38

标签: html twitter-bootstrap affix

我做了一个代码,但是没有出现在右侧的afiz不知道为什么,请帮忙吗? 在css我添加它

.affix {
    top:100px;
}

只需要知道错误在哪里,因为我无法理解它= \



   
<body data-spy="scroll" data-target="#myScrollspy" data-offset="200">
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <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="index.html"><img src="img/logo.png" height=30 width=41></a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="index.html"><span class="glyphicon glyphicon-home"
                         aria-hidden="true"></span> Home</a></li>
                    <li class="active"> <a href="aboutus.html"><span class="glyphicon glyphicon-info-sign"
                         aria-hidden="true"></span> About</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                         role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-list-alt" arria-hidden="true"></span>
                         Menu <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Appetizers</a></li>
                            <li><a href="#">Main Courses</a></li>
                            <li><a href="#">Desserts</a></li>
                            <li><a href="#">Drinks</a></li>
                            <li role="separator" class="divider"></li>
                            <li class="dropdown-header">Specials</li>
                            <li><a href="#">Lunch Buffet</a></li>
                            <li><a href="#">Weekend Brunch</a></li>
                        </ul>
                    </li>
                    <li><a href="contactus.html"><i class="fa fa-envelope-o" ></i>Contact</a></li>
                </ul>
            </div>
        </div>
    </nav>  
    <header class="jumbotron">

        <!-- Main component for a primary marketing message or call to action -->

        <div class="container">
            <div class="row row-header">
                <div class="col-xs-12 col-sm-8">
                    <h1>Ristorante con Fusion</h1>
                    <p style="padding:40px;"></p>
                    <p>We take inspiration from the World's best cuisines, and create a unique fusion experience. Our lipsmacking creations will tickle your culinary senses!</p>
                </div>
                 <div class="col-xs-12 col-sm-2">
                    <p style="padding:20px;"></p>
                    <img src="img/logo.png" class="img-responsive">
                </div>
            </div>
        </div>
    </header>

    <div class="container">
       <div class="row">
       <div class="col-xs-12 col-sm-10">
            <div class="row">
                <div class="col-xs-12">
               <ol class="breadcrumb">
                    <li><a href="index.html">Home</a></li>
                    <li class="active">About</li>
                </ol>
            </div>
            
            
             <div class="col-xs-12">
               <h3>About Us</h3>
               <hr>
            </div>
        </div>
            
            <div id="history" class="row row-content">
			<div class="col-xs-12 col-sm-6 col-lg-8">
                <h2>Our History</h2>
                <p>Started in 2010, Ristorante con Fusion quickly established itself as a culinary icon par excellence in Hong Kong. With its unique brand of world fusion cuisine that can be found nowhere else, it enjoys patronage from the A-list clientele in Hong Kong.  Featuring four of the best three-star Michelin chefs in the world, you never know what will arrive on your plate the next time you visit us.</p>
                <p>The restaurant traces its humble beginnings to <em>The Frying Pan</em>, a successful chain started by our CEO, Mr. Peter Pan, that featured for the first time the world's best cuisines in a pan.</p>
                
                 <div class="well">
                    <blockquote>
                        <p>You better cut the pizza in four pieces because
                            I'm not hungry enough to eat six.</p>
                        <footer>Yogi Berra,
                          <cite>The Wit and Wisdom of Yogi Berra,
                            P. Pepe, Diversion Books, 2014</cite>
                        </footer>
                    </blockquote>
                </div>
            </div>
                <div class="col-xs-12 col-sm-6 col-lg-4">   
             <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">Facts At a Glance</h3>
                    </div>
                    <div class="panel-body">
                        <dl class="dl-horizontal">
                            <dt>Started</dt>
                            <dd>3 Feb. 2013</dd>
                            <dt>Major Stake Holder</dt>
                            <dd>HK Fine Foods Inc.</dd>
                            <dt>Last Year's Turnover</dt>
                            <dd>$1,250,375</dd>
                            <dt>Employees</dt>
                            <dd>40</dd>
                       </dl>
                    </div>
                </div>
    </div>
			</div>
             
            <div>
                <p style="padding:20px;"></p>
               
            </div>


            <div id="corporate" class="row row-content">
			<div class="col-xs-12 ">
                <h2>Corporate Leadership</h2>
                      
                <!--- Tab Panes --->
                <div class="panel-group" id="accordion"
                      role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingPeter">
                            <h3 class="panel-title">
                                <a role="button" data-toggle="collapse"
                                     data-parent="#accordion" href="#peter"
                                     aria-expanded="true" aria-controls="peter">
                        Peter Pan <small>Chief Epicurious Officer</small></a></h3>
                        
                </div>
                        
                <div role="tabpanel" class="panel-collapse collapse in"
                             id="peter"    aria-labelledby="headingPeter">
                            <div class="panel-body">
                <p>Our CEO, Peter, credits his hardworking East Asian immigrant parents who undertook the arduous journey to the shores of America with the intention of giving their children the best future. His mother's wizardy in the kitchen whipping up the tastiest dishes with whatever is available inexpensively at the supermarket, was his first inspiration to create the fusion cuisines for which <em>The Frying Pan</em> became well known. He brings his zeal for fusion cuisines to this restaurant, pioneering cross-cultural culinary connections.</p>
                                
                    </div>
                    </div>
                    </div>
                    
                <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingDanny">
                            <h3 class="panel-title">
                                <a class="collapsed" role="button" data-toggle="collapse"
                                     data-parent="#accordion" href="#danny"
                                     aria-expanded="false" aria-controls="danny">
                    Dhanasekaran Witherspoon <small>Chief Food Officer</small></a></h3>
                    </div>
                    <div role="tabpanel" class="panel-collapse collapse"
                             id="danny"    aria-labelledby="headingDanny">
                            <div class="panel-body">
                <p>Our CFO, Danny, as he is affectionately referred to by his colleagues, comes from a long established family tradition in farming and produce. His experiences growing up on a farm in the Australian outback gave him great appreciation for varieties of food sources. As he puts it in his own words, <em>Everything that runs, wins, and everything that stays, pays!</em></p>
                        </div>
                    </div>
                    </div>
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingAgumbe">
                            <h3 class="panel-title">
                                <a class="collapsed" role="button" data-toggle="collapse"
                                     data-parent="#accordion" href="#agumbe"
                                     aria-expanded="false" aria-controls="agumbe">
                                     Agumbe Tang <small>Chief Taste Officer</small></a></h3>
                    </div>
                   <div role="tabpanel" class="panel-collapse collapse"
                             id="agumbe"    aria-labelledby="headingAgumbe">
                            <div class="panel-body">
                <p>Blessed with the most discerning gustatory sense, Agumbe, our CFO, personally ensures that every dish that we serve meets his exacting tastes. Our chefs dread the tongue lashing that ensues if their dish does not meet his exacting standards. He lives by his motto, <em>You click only if you survive my lick.</em></p>
                     </div>
                     </div>
                    </div>
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingAlberto">
                            <h3 class="panel-title">
                                <a class="collapsed" role="button" data-toggle="collapse"
                                     data-parent="#accordion" href="#alberto"
                                     aria-expanded="false" aria-controls="alberto">
                            Alberto Somayya <small>Executive Chef</small></a></h3>
                    </div>
                  <div role="tabpanel" class="panel-collapse collapse"
                             id="alberto"    aria-labelledby="headingAlberto">
                            <div class="panel-body">

                <p>Award winning three-star Michelin chef with wide International experience having worked closely with whos-who in the culinary world, he specializes in creating mouthwatering Indo-Italian fusion experiences. He says, <em>Put together the cuisines from the two craziest cultures, and you get a winning hit! Amma Mia!</em></p>
                    </div>
                      </div>
                        </div>
                    </div>
            </div>
            </div>
			</div>
             <div>
                <p style="padding:20px;"></p>
            </div>
                 <div id="facts" class="row row-content">
            <div class="col-xs-12">
                <h2>Facts &amp; Figures</h2>
                <div class="table-responsive">
                <table class="table table-striped">
                    <tr>
                        <td>&nbsp;</td>
                        <th>2013</th>
                        <th>2014</th>
                        <th>2015</th>
                    </tr>
                    <tr>
                        <th>Employees</th>
                        <td>15</td>
                        <td>30</td>
                        <td>40</td>
                    </tr>
                    <tr>
                        <th>Guests Served</th>
                        <td>15000</td>
                        <td>45000</td>
                        <td>100,000</td>
                    </tr>
                    <tr>
                        <th>Special Events</th>
                        <td>3</td>
                        <td>20</td>
                        <td>45</td>
                    </tr>
                    <tr>
                        <th>Annual Turnover</th>
                        <td>$251,325</td>
                        <td>$1,250,375</td>
                        <td>~$3,000,000</td>
                    </tr>
                </table>
                </div>
            </div>
           </div>
        </div>
                     
            <nav class="hidden-xs col-sm-2" id="myScrollspy">
            <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="400">
                <li><a href="#history">Our History</a></li>
                <li><a href="#corporate">Corporate</a></li>
                <li><a href="#facts">Facts</a></li>
            </ul>
        </nav>
                   </div> 
            
            </div>

    <footer class="row-footer">
        <div class="container">
            <div class="row">             
                <div class="col-xs-5 col-xs-offset-1 col-sm-2 col-sm-offset-1">
                    <h5>Links</h5>
                    <ul class="list-unstyled">
                        <li><a href="index.html">Home</a></li>
                        <li><a href="aboutus.html">About</a></li>
                        <li><a href="#">Menu</a></li>
                        <li><a href="#">Contact</a></li>
                    </ul>
                </div>
                <div class="col-xs-6 col-sm-5">
                    <h5>Our Address</h5>
                    <address>
		              121, Clear Water Bay Road<br>
		              Clear Water Bay, Kowloon<br>
		              HONG KONG<br>
		              <i class="fa fa-phone"></i>: +852 1234 5678<br>
		              <i class="fa fa-fax"></i>: +852 8765 4321<br>
		              <i class="fa fa-envelope"></i>: 
                        <a href="mailto:confusion@food.net">confusion@food.net</a>
		           </address>
                </div>
                <div class="col-xs-12 col-sm-4">
                    <div class="nav navbar-nav" style="padding: 40px 10px;">
                        <a class="btn btn-social-icon btn-google-plus" href="http://google.com/+"><i class="fa fa-google-plus"></i></a>
                        <a class="btn btn-social-icon btn-facebook" href="http://www.facebook.com/profile.php?id="><i class="fa fa-facebook"></i></a>
                        <a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/in/"><i class="fa fa-linkedin"></i></a>
                        <a class="btn btn-social-icon btn-twitter" href="http://twitter.com/"><i class="fa fa-twitter"></i></a>
                        <a class="btn btn-social-icon btn-youtube" href="http://youtube.com/"><i class="fa fa-youtube"></i></a>
                        <a class="btn btn-social-icon" href="mailto:"><i class="fa fa-envelope-o"></i></a>
                    </div>
                </div>
                <div class="col-xs-12">
                    <p style="padding:10px;"></p>
                    <p align=center>© Copyright 2015 Ristorante Con Fusion</p>
                </div>
            </div>
        </div>
    </footer>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
</body>

</html>
&#13;
&#13;
&#13;

为什么出现在中间?

2 个答案:

答案 0 :(得分:0)

您在主container内有滚动代码,它在页面主视图中“包含”它。

将此代码移至开头<body>标记的正下方,它应该有效。

<body> 
<nav class="hidden-xs col-sm-2" id="myScrollspy">
    <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="400">
        <li><a href="#history">Our History</a></li>
        <li><a href="#corporate">Corporate</a></li>
        <li><a href="#facts">Facts</a></li>
    </ul>
</nav>

答案 1 :(得分:0)

我把它当作了 你出现在页面和左侧的开始,但我想在右侧和orkins 200px之后orkins

&#13;
&#13;
<body data-spy="scroll" data-target="#myScrollspy" data-offset="200">
     <nav class="hidden-xs col-sm-2" id="myScrollspy">
            <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="400">
                <li><a href="#history">Our History</a></li>
                <li><a href="#corporate">Corporate</a></li>
                <li><a href="#facts">Facts</a></li>
            </ul>
        </nav>
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
&#13;
&#13;
&#13;