CSS to achieve a similar fixed floating div thast always on top of other divs - like stackoverflow does?

强颜欢笑 提交于 2019-12-04 13:16:56

问题


I'd like to achieve a similar effect as the one in this image:

Basically, I want to have a div as a menu bar that's always on top - the div beneath it being the container div for my content. Clicking any links in my menu bar only change the content in the container div.


回答1:


You need to use the position: fixed; property for #top div.

<div id="top"></div>

#top {
  position:fixed;
  top:0px;
  width:100%;
  height:70px;
}



回答2:


You need to have a div and assign the CSS classes:

.className {
width: 100%;
position: fixed;
top: 0px;
height: 75px;
}

Then on your div have: <div class="className">Whatever</div>



来源:https://stackoverflow.com/questions/5206413/css-to-achieve-a-similar-fixed-floating-div-thast-always-on-top-of-other-divs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!