简体   繁体   中英

How to exclude item from collapse in bootstrap navbar

I have been wanting to exclude a certain item on the navbar from the collapse box when the screen becomes small.

This is the HTML code I have so far:

    <div class="container">
  <nav class="navbar navbar-default">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navBar">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="."><img class="ico_img" src="assets/ico_img.png" /></a>
      </div>
      <div class="collapse navbar-collapse" id="navBar">
        <ul class="nav navbar-nav">
          <li class="active"><a>Home</a></li>
          <li><a href="page1.php">Page 1</a></li>
          <li><a href="page2.php">Page 2</a></li>
          <li><a href="page3.php">Page 3</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right hidden-xs">
          <li><a class="welcome"></a></li>
        </ul>
      </div>
    </div>
  </nav>
</div>

I would like to exclude the welcome part. One solution I have found thus far is by adding the 'hidden-xs' class attribute to hide the welcome message when the collapse toggle appears, but is there a cleaner way to do this?

You can do it with a bunch of .visibble-*-*. It's cleaner with an .hidden-xs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM