2016-01-13 81 views
0

我有一個複雜的導航設置,我嘗試使用sidr來實現響應菜單。我已經爲主菜單工作,但是當我將div id =「navigation」添加到我的社交菜單時,它只是在sidr菜單中顯示。我也想在我的sidr菜單中包含搜索。這裏是我的代碼:如何在一個sidr菜單上顯示多個菜單

<header> 
    <div id="mobile-header"> 
     <a id="responsive-menu-button" href="#sidr-main">Menu</a> 
    </div> 
    <div class="whiteBar"> 
     <div class="container"> 
      <div class="row"> 
       <div class="logo"> 
        <a href="<?php echo $directory; ?>index.php"><img src="<?php echo $directory; ?>_images/global/logo.png" alt="Caterpillar 2015 Year in Review"></a> 
       </div> 
       <div class="reportTitle"> 
        <h1>2015 Year in Review</h1> 
       </div> 
       <div class="searchWrapper"> 
        <div class="search"> 
         <form method="get" action="search.php"> 
          <input type="text" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required=""> 
          <button type="submit"><img src="<?php echo $directory; ?>_images/global/icnSearch.png"></button> 
         </form> 
        </div> 
       </div> 
       <div id="navigation"> 
        <nav class="social"> 
         <ul> 
          <li class="share">Share</li> 
          <li><a class="linkedin gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnLinkedIn.png"></a></li> 
          <li><a class="google gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnGoogle.png"></a></li> 
          <li><a class="twitter gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnTwitter.png"></a></li> 
          <li><a class="facebook gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnFacebook.png"></a></li> 
         </ul> 
        </nav> 
       </div> 
      </div> 
     </div> 
    </div> 
    <div class="yellowBar"> 
     <div class="container"> 
      <div id="navigation"> 
       <div class="row"> 
        <nav class="mainMenu nav"> 
         <ul> 
          <li><a href="<?php echo $directory; ?>leadership/letter.php">Leadership</a></li> 
          <li><a href="<?php echo $directory; ?>data/landing.php">Data &amp; Innovation</a></li> 
          <li><a href="<?php echo $directory; ?>efficiency/landing.php">Efficiency</a></li> 
          <li><a href="<?php echo $directory; ?>support/landing.php">Customer Support</a></li> 
          <li><a href="<?php echo $directory; ?>people/landing.php">People</a></li> 
          <li><a class="reviewLink" href="<?php echo $directory; ?>review/landing.php">Business Review</a></li> 
         </ul> 
        </nav> 
        <div class="report link"> 
         <a class="gaClick" href="http://www.corporatereport.com/client/caterpillar/2015/sr/" target="_blank"><img src="<?php echo $directory; ?>_images/global/icnDownload.png">Download PDF Version</a> 
        </div> 
        <div class="download link"> 
         <a class="gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnSR.png">2015 Sustainability Report</a> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</header> 

有關如何做到這一點的任何想法?文檔並沒有很好地解釋這一點。

謝謝!

+0

分享CSS /小提琴伴侶 – Siddharth

+0

我無法讓js小提琴上班。 https://jsfiddle.net/rkxrvt63/ – blahblahAMYblah

+0

我有我的js錯誤的順序。這應該工作。 https://jsfiddle.net/rkxrvt63/2/ – blahblahAMYblah

回答

1

我想通了!我只需要在JS中的#navigation後添加逗號,然後執行#navigation2。這裏是工作提琴:https://jsfiddle.net/rkxrvt63/5/ \

HTML:

<header> 
    <div id="mobile-header"> 
     <a id="responsive-menu-button" href="#sidr-main">Menu</a> 
    </div> 
    <div class="whiteBar"> 
     <div class="container"> 
      <div class="row"> 
       <div class="logo"> 
        <a href="<?php echo $directory; ?>index.php"><img src="<?php echo $directory; ?>_images/global/logo.png" alt="Caterpillar 2015 Year in Review"></a> 
       </div> 
       <div class="reportTitle"> 
        <h1>2015 Year in Review</h1> 
       </div> 
       <div id="navigation2"> 
       <div class="searchWrapper"> 
        <div class="search"> 
         <form method="get" action="search.php"> 
          <input type="text" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required=""> 
          <button type="submit"><img src="<?php echo $directory; ?>_images/global/icnSearch.png"></button> 
         </form> 
        </div> 
       </div> 
       <nav class="social"> 
        <ul> 
         <li class="share">Share</li> 
         <li><a class="linkedin gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnLinkedIn.png"></a></li> 
         <li><a class="google gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnGoogle.png"></a></li> 
         <li><a class="twitter gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnTwitter.png"></a></li> 
         <li><a class="facebook gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnFacebook.png"></a></li> 
        </ul> 
       </nav> 
       </div> 
      </div> 
     </div> 
    </div> 
    <div class="yellowBar"> 
     <div class="container"> 
      <div id="navigation"> 
       <div class="row"> 
        <nav class="mainMenu nav"> 
         <ul> 
          <li><a href="<?php echo $directory; ?>leadership/letter.php">Leadership</a></li> 
          <li><a href="<?php echo $directory; ?>data/landing.php">Data &amp; Innovation</a></li> 
          <li><a href="<?php echo $directory; ?>efficiency/landing.php">Efficiency</a></li> 
          <li><a href="<?php echo $directory; ?>support/landing.php">Customer Support</a></li> 
          <li><a href="<?php echo $directory; ?>people/landing.php">People</a></li> 
          <li><a class="reviewLink" href="<?php echo $directory; ?>review/landing.php">Business Review</a></li> 
         </ul> 
        </nav> 
        <div class="report link"> 
         <a class="gaClick" href="http://www.corporatereport.com/client/caterpillar/2015/sr/" target="_blank"><img src="<?php echo $directory; ?>_images/global/icnDownload.png">Download PDF Version</a> 
        </div> 
        <div class="download link"> 
         <a class="gaClick" href="#"><img src="<?php echo $directory; ?>_images/global/icnSR.png">2015 Sustainability Report</a> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</header> 

JS:

$('#responsive-menu-button').sidr({ 
    name: 'sidr-main', 
    source: '#navigation, #navigation2', 
    side: 'right' 
}); 

CSS:

#mobile-header { 
    display: none; 

    .navigation::after { 
     content: none; 
    } 
} 
@media only screen and (max-width: 1150px){ 
    #mobile-header { 
     display: block; 
    } 
    .yellowBar { 
     display: none; 
    } 
} 
相關問題