[英]Prevent content from hiding behind fixed position navigation bar
I have a navigation bar with 40px height and I can't place my other content (just a textarea) below this bar. 我有一个高度为40px的导航栏,我无法将其他内容(仅文本区域)放在该栏的下方。 I tried to set margin-top:40px;
我试图设置margin-top:40px;
to the textarea but it doesn' t work. 到textarea,但是它不起作用。
Then I used padding-top:40px
which is ok for the content inside the textarea but as you will see has a problem with the scrollbar (it gets behind the bar). 然后,我使用padding-top:40px
可以处理文padding-top:40px
的内容,但是您会看到滚动条有问题(滚动条后面有问题)。
向导航padding-bottom: 40px
添加padding-bottom: 40px
,并将其从文本区域中删除。
use 采用
postion:fixed;
and margin to push contents out
As an alternative to @Andrw Ice 's answer 作为@Andrw Ice的答案的替代方法
You just have to give the textarea
s margin something to push against. 您只需要给textarea
的空白添加一些内容即可。
This is common...as the advantage is that it doesn't cause any of the elements to moveif the navbar is hidden. 这很常见,因为优点是如果导航栏被隐藏,它不会导致任何元素移动。
body {
border:1px solid transparent;
}
nav + textarea{
margin-top: 40px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.