dongwuxie7976
dongwuxie7976
2017-05-02 10:11
浏览 15
已采纳

Bootstrap导航栏内容对不对?

I am having an issue with my bootstrap navbar. I would like to divide the content where the categories are on the left and the log in details are on the left.

For example: Brädspel Samlarkortspel Figurspel Tillbehör list stays on the left while: Registrera Logga in Önskelista (0) Kundvagn Kassan stays on the right. I have tried using <ul class="nav navbar-nav navbar-right"> However it dosent work properly. Here is the whole website navbar: http://www.bradspelskafeet.se/index.php

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<a href="index.php"><img src="image/samspel.png" alt="mainlogo" class="img-responsive center-block" height="200px" width="200px"></a>
<br>
<?php if ($categories) { ?>
<div class="container">
  <nav id="menu" class="navbar">

    <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
        <?php
            if (isset($_GET['path'])) {
              $parts = explode('_', (string)$_GET['path']);
            } else {
              $parts = array();
            }

            if (isset($parts[0])) {
              $category_id = $parts[0];
            }
        ?>
        <?php foreach ($categories as $category) { ?>
        <?php if (isset($category_id) && isset($category['category_id']) && $category['category_id'] == $category_id) { ?>
        <li name="<?php echo $category['name']; ?>" class="open"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } else { ?>
        <li name="<?php echo $category['name']; ?>"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } ?>
        <?php } ?>
          <?php echo $currency; ?>
          <?php echo $language; ?>
                  <?php if ($logged) { ?>

                  <li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li>
                  <li><a href="<?php echo $order; ?>"><?php echo $text_order; ?></a></li>

                  <li><a href="<?php echo $transaction; ?>"><?php echo $text_transaction; ?></a></li>
                  <li><a href="<?php echo $download; ?>"><?php echo $text_download; ?></a></li>
                  <li><a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a></li>
                  <?php } else { ?>
                  <li><a href="<?php echo $register; ?>"><?php echo $text_register; ?></a></li>
                  <li><a href="<?php echo $login; ?>"><?php echo $text_login; ?></a></li>
                  <?php } ?>
              <li><a href="<?php echo $wishlist; ?>" id="wishlist-total" title="<?php echo $text_wishlist; ?>"><i class="fa fa-heart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_wishlist; ?></span></a></li>
              <li><a href="<?php echo $shopping_cart; ?>" title="<?php echo $text_shopping_cart; ?>"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_shopping_cart; ?></span></a></li>
              <li><a href="<?php echo $checkout; ?>" title="<?php echo $text_checkout; ?>"><i class="fa fa-share"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_checkout; ?></span></a></li>
      </ul>
    </div>
  </div>
  </nav>
</div>
<?php } ?>

</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpgu5074
    dpgu5074 2017-05-02 11:38
    已采纳

    make a structure like this, and you have done

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <nav class="navbar navbar-inverse">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>                        
          </button>
          <a class="navbar-brand" href="#">WebSiteName</a>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
          <ul class="nav navbar-nav">
              <li><a href="#">Brädspel</a></li>
           <li><a href="#">Samlarkortspel</a></li>
           <li><a href="#">Figurspel</a></li>
            <li><a href="#">Tillbehör</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
        <li class=""><a href="#">Registrera</a></li>
            <li class=""><a href="#">Logga in</a></li>
              <li class=""><a href="#">  Önskelista (0)</a></li>
            <li class=""><a href="#">Kundvagn</a></li>
              <li class=""><a href="#">Kassan</a></li>
          </ul>
        </div>
      </div>
    </nav>

    </div>
    
    点赞 评论

相关推荐