如何在页面右侧制作粘性导航栏?

问题描述 投票:0回答:1

Image我想建立一个在右侧带有导航栏的网站。我是Web开发的新手。我怎样才能做到这一点?谢谢。

bootstrapping
1个回答
0
投票

通常来说,将导航栏放在右侧是种很奇怪的想法。所有浏览器都将滚动条置于右侧。

无论如何

您应将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>
© www.soinside.com 2019 - 2024. All rights reserved.