Why is my bootstrap navbar not displaying inline?

后端 未结 11 2245
感情败类
感情败类 2021-01-01 20:46

Here is my html using bootstrap (I\'m sure bootstrap is installed correctly)

11条回答
  •  旧巷少年郎
    2021-01-01 21:22

    This is because in Bootstrap the css for li is this:

    .nav>li {
      position: relative;
      display: block;
    }
    

    But for me the menu seems to appear correctly. See snippet, but only on a full page. On mobile devices it will behave like a block element since the screen doesn't have room to show them inline.

    EDIT: Updated the snippit to work as requested (see comments below this answer)

    .navbar .container-fluid>.navbar-header {
      float: left;
      margin-right: 10px;
    }
    .navbar .navbar-nav {
      float: left;
      margin: 5px;
    }
    .nav>li {
      float: left;
    }
    
    
    

提交回复
热议问题