通常来说,将导航栏放在右侧是种很奇怪的想法。所有浏览器都将滚动条置于右侧。
无论如何
您应将CSS应用于站点。
.navbar{
background-color:red;
position:sticky;
height:100vh;
top:0;
float:right;
}
.content{
height:2000px;
margin-top:10px;
margin-right:120px;
border: 1px solid red;
}
并且在html中
<div class="navbar">
This is the navbar
</div>
<div class="content">
Content
</div>