【发布时间】:2021-12-04 06:48:04
【问题描述】:
这是一个 Angular 12 项目。我有一个用固定位置定义的侧边栏。它位于应用程序组件中,因此出现在每个页面上。但是,当我点击主页按钮时,如何确保主页中的内容始终位于右侧侧边栏之后,并且左侧和右侧之间的间距相等?
这是我的代码:
<nav class="navbar navbar-expand d-flex flex-column align-item-start sidebar">
<a class="navbar-brand mt-2">
<img [src]="IconUrl" height="50" width="120">
</a>
<ul class="navbar-nav d-flex flex-column mt-2 w-100">
<li class="nav-item w-100">
<a class="nav-link text-light pl-4" [routerLink]="['home']"
routerLinkActive="active"><i class="fa fa-home me-2"></i>Home</a>
</li>
</nav>
styles.scss
.sidebar {
width: 20%;
height: 100vh;
position: fixed;
background-color: $purple;
transition: all 0.4s ease;
color: $white;
}
【问题讨论】:
标签: html css angular twitter-bootstrap