如何编辑 bootstrap 导航栏?
How to edit bootstrap navbar?
我正在尝试制作一个 angular 应用程序,我正在使用 bootstrap@5.0.2
。在导航栏中,我有两个链接,我想将其移至右侧。但我做不到。我该怎么办?
This is the problem
HTML代码:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">HOMEPAGE</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<span class="navbar-text">
<a routerLink="/homepage/registration">Registration</a>
</span>
<span class="navbar-text">
<a routerLink="/homepage/login">Login</a>
</span>
</ul>
</div>
</div>
</nav>
<router-outlet></router-outlet>
像这样在 ul
标签前使用弹性垫片
<span class="flex-spacer"></span>
在css
中添加class
.flex-spacer {
flex: 1 1 auto;
}
您的代码将是
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">HOMEPAGE</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<span class="flex-spacer"></span>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<span class="navbar-text">
<a routerLink="/homepage/registration">Registration</a>
</span>
<span class="navbar-text">
<a routerLink="/homepage/login">Login</a>
</span>
</ul>
</div>
</div>
</nav>
<router-outlet></router-outlet>
这是它的样子
希望对您有所帮助。
将 CSS 应用于您的组件
#navbarSupportedContent{
position: absolute;
float: right;
right: 20px;
}
.navbar-nav{
gap: 10px;
}
我正在尝试制作一个 angular 应用程序,我正在使用 bootstrap@5.0.2
。在导航栏中,我有两个链接,我想将其移至右侧。但我做不到。我该怎么办?
This is the problem
HTML代码:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">HOMEPAGE</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<span class="navbar-text">
<a routerLink="/homepage/registration">Registration</a>
</span>
<span class="navbar-text">
<a routerLink="/homepage/login">Login</a>
</span>
</ul>
</div>
</div>
</nav>
<router-outlet></router-outlet>
像这样在 ul
标签前使用弹性垫片
<span class="flex-spacer"></span>
在css
中添加class.flex-spacer {
flex: 1 1 auto;
}
您的代码将是
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">HOMEPAGE</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<span class="flex-spacer"></span>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<span class="navbar-text">
<a routerLink="/homepage/registration">Registration</a>
</span>
<span class="navbar-text">
<a routerLink="/homepage/login">Login</a>
</span>
</ul>
</div>
</div>
</nav>
<router-outlet></router-outlet>
这是它的样子
希望对您有所帮助。
将 CSS 应用于您的组件
#navbarSupportedContent{
position: absolute;
float: right;
right: 20px;
}
.navbar-nav{
gap: 10px;
}