我希望使用navbar-collapse BS4时某些元素不会折叠

时间:2019-04-07 05:33:36

标签: bootstrap-4 navbar

因为我的英语不好,请原谅我。

我在https://jsfiddle.net/3vmajng0/上有这个导航栏

<nav class="navbar navbar-expand-lg navbar-light bg-light sb-navbar">
  <div class="container">
    <a class="navbar-brand" data-toggle="collapse" data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="ml-1">Start Bootstrap</span>
    </a>
        <div class="avatar-image">
    </div>
    <div class="navbar-collapse collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto pt-3 pt-lg-0">
        <li class="nav-item">
          <a class="nav-link" routerLink="/">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" routerLink="/item">Product</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" routerLink="/about">About Us</a>
        </li>
      </ul>
    </div>

  </div>
</nav>

当我单击“启动引导程序”文本时,将显示菜单,但头像也会向下推菜单。见下图 https://i.imgur.com/OhILgEc.png

但是我希望它看起来像这样 enter image description here

我试图将“头像” div折叠起来,但是当在PC上看到时, enter image description here

再次抱歉,因为我无法发布图片。它说:“您至少需要10个信誉才能发布图像”

有人对我有解决办法吗?

2 个答案:

答案 0 :(得分:0)

如果没有,请应用css部分

.avatar-image {
    background-image: url('https://avatars.servers.getgo.com/2205256774854474505_medium.jpg');
    background-size: cover;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

答案 1 :(得分:0)

@variable类中添加float: right属性。

.avatar-image
.avatar-image {
    float: right;
    background-image: url('https://avatars.servers.getgo.com/2205256774854474505_medium.jpg');
    background-size: cover;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}