简体   繁体   English

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

[英]How to make a sticky navigation bar on the right side of the page?

图片 I would like to build a site with a stick nav bar on the right side.我想在右侧建立一个带有导航条的站点。 I'm new to web development.我是 web 开发的新手。 How can I achieved this?我怎样才能做到这一点? Thank you.谢谢你。

Generally to speak this is kind of a wierd idea to put a navbar to the right side.一般来说,将导航栏放在右侧是一种奇怪的想法。 All the browsers put the scrolbar to te right side.所有浏览器都将滚动条放在右侧。

Anyways无论如何

you should apply css to the site.您应该将 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;
}

And in the html并在 html

<div class="navbar">
   This is the navbar
</div>
<div class="content">
  Content
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM