这是否可以通过Twitter Bootstrap实现 http://www.usatoday.com/opinion/
向下滚动时,只有菜单部分应保留在顶部?如果有人有方便的jsfiddle版本,那将是非常好的。
答案 0 :(得分:0)
您可以通过使用导航栏并使用affix plugin来使其正常工作。我在这里有一个(非常粗略)的工作示例:http://bootply.com/87472。重要的部分在CSS中:
header { //this is whatever is sitting above the navbar.
height:50px; //this can be set to anything, just make it match
//the data-offset-top in the HTML (see below)
}
.affix {
width:100%; //makes sure the "affixed" navbar stretches the full width
top:0; //makes it stick to the top when it gets there.
}
.affix + p { //this is whatever is sitting below the navbar
margin-top:70px; //set to the total height of your navbar
}
您需要的HTML中的位:
<div class="navbar navbar-default" data-spy="affix" data-offset-top="50">
如上所述,data-offset-top
应与位于导航栏上方的任何元素的总高度相匹配。
至于花哨的效果,我建议你查看css transitions来发挥这种神奇的效果。