1

我正在使用 bootstrap3 设计一个菜单。它应该看起来像图片中显示的那样。但我无法创建这样的菜单。我试过创建一个,我的设计链接是https://codepen.io/irshad437/pen/EyQLVv

下面还显示了一些代码。但是你必须在 Codepen.io 上检查它(这里不好看)

    <nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <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="#">MyGrade <span class="circle-txt">Up</span></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="#">HOME</a></li>
        <hr class="vertical" />
        <li><a href="#">EXPLORE</a></li>
      </ul>
      <form class="navbar-form navbar-right" role="search">
        <button type="submit" class="btn btn-default btn-rnd">Create Portfolio</button>
      </form>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Anonymous <br />0 pts</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <img class="img-circle nav-img" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/677716/profile/profile-80_1.jpg" alt="?" class="img-round"/>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>



.btn-rnd{
  border-radius:10px;
}

.navbar-nav li{
  margin-left:20px;
  margin-right:20px;
}

.nav-img{
  width:40px;
  height:40px;
}

.vertical{
  position:absolute;
  width:1px;
  height:25px;
  color: black;
  background-color:black;
  display:inline-block;
}

.padding-8{
  padding-top:8px;
}

.img-circle{
  border: 1px solid black;
}

.circle-txt{
  height: 40px;
  width: 40px;
  display: inline-block;
  text-align: center;
  vertical-align: -10px;
  padding-top:8px;
  border-radius: 50%;
  background: white;
  border-style:solid;
  border-width:1px;
}



问题:我无法将像素固定在设计中所示的正确位置。

这就是它应该的样子。

4

1 回答 1

1

这应该可以正常工作,看看,这里是修复。

https://codepen.io/anon/pen/QEmZWR

HTML:

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <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="#">MyGrade <span class="circle-txt">Up</span></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="#">HOME</a></li>
        <hr class="vertical" />
        <li><a href="#">EXPLORE</a></li>
      </ul>
      <form class="navbar-form navbar-right" role="search">
        <button type="submit" class="btn btn-default btn-rnd">Create Portfolio</button>
      </form>
      <ul class="annon nav navbar-nav navbar-right">
        <li><a href="#">Anonymous <br />0 pts</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <img class="img-circle nav-img" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/677716/profile/profile-80_1.jpg" alt="?" class="img-round"/>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

CSS:

.btn-rnd{
  border-radius:10px;
}

.navbar-nav li{
  margin-left:20px;
  margin-right:20px;
}

.nav-img{
  width:40px;
  height:40px;
}

.vertical{
  position:absolute;
  width:1px;
  height:25px;
  color: black;
  background-color:black;
  display:inline-block;
}

.padding-8{
  padding-top:8px;
}

.img-circle{
  border: 1px solid black;
}

.circle-txt{
  height: 40px;
  width: 40px;
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  padding-top:8px;
  border-radius: 50%;
  background: white;
  border-style:solid;
  border-width:1px;
}

a{
  margin: 0px;
  padding: 0px;
}

.navbar-nav li{
  margin-top:10px;
}

.navbar-form .btn{
  margin-top:10px;
}

.annon li{
  margin:0px;
} 
.navbar-nav .img-circle{
  padding:0xp;
  margin-top:13px;
}

于 2016-07-22T15:58:21.190 回答