我正在尝试使用Angular和Bootstrap构建一个渐进式Web应用程序。最具挑战性的部分是实现一个导航栏,该导航栏在Web和移动视图上看起来都不错。到目前为止,我对自己的实现大部分都非常满意。请参阅Stackblitz
上的链接但是现在,我试图将导航栏切换为侧边栏,从右向左打开。另外,侧边栏应将内容(占位符文本)推到左侧。这可能有点困难,因为这可能意味着修改某些Bootstrap类。也许有些人对此有解决方案。目前,我的导航栏在下面切换链接。
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<ul class="navbar-nav">
<li class="nav-item">
<a class="navbar-brand d-none d-md-block" href="javascript:void(0)">
<img alt="logo" src="https://..." width="40px" height="auto">
My Brand
</a>
</li>
</ul>
<ul class="navbar-nav mr-auto mr-md-3">
<li class="nav-item">
<a class="nav-link font-weight-bold" href="javascript:void(0)">Stories</a>
</li>
</ul>
<ul class="navbar-nav mr-auto mr-md-3">
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)">
<span>
<img class="rounded" src="https://..." alt="user" width="35" height="35">
<span class="d-none d-lg-inline"> Tommy</span>
</span>
</a>
</li>
</ul>
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link font-weight-bold" href="javascript:void(0)">
<div class="img-container" (click)="notificationsViewed = true">
<img alt="notifications" src="https://..." width="35">
<span [hidden]="notificationsViewed" class="badge badge-danger notifications-count">raywenderlich.com</span>
</div>
</a>
</li>
</ul>
<button class="navbar-toggler" (click)="toggleNavbar()" type="button" [attr.aria-expanded]="!isCollapsed">
<span class="icon-bar top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
</button>
<div class="collapse navbar-collapse" [ngClass]="{ 'show': isCollapsed }">
<ul class="navbar-nav float-right ml-auto">
<li class="nav-item">
<a class="nav-link font-weight-bold" href="javascript:void(0)">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link font-weight-bold"href="javascript:void(0)">Policy</a>
</li>
<li class="nav-item">
<a class="nav-link font-weight-bold" href="javascript:void(0)">Contact</a>
</li>
<li class="nav-item">
<button (click)="logout()" class="btn btn-bd-logout">
Logout
</button>
</li>
</ul>
</div>
</nav>
public isCollapsed: boolean = false;
toggleNavbar() {
this.isCollapsed = !this.isCollapsed;
}
答案 0 :(得分:0)