[position: fixed ] with vertical space

[url=http://stackoverflow.com/questions/5363430/position-fixed-with-vertical-space][size=large][b]Position: fixed with vertical space[/b][/size][/url]

What I have is a rather basic issue with position: fixed.

Here's a sample: http://jsfiddle.net/wxEsY/

What I want is the scrolling to start below the black bar (with a fixed position).

Any help appreciated.

Regards


_______________________________________________________________________

Does this do it?

http://jsfiddle.net/Vqncx/

I just gave the 'content' DIV relative positioning and a y-axis from the top equal to the height of the 'nav' and then gave the 'nav' a z-index to keep it on top of the 'content'.




.nav {
width: 100%;
height: 50px;
background: #000;
position: fixed;
z-index: 5;
}

.content {
background: #ccc;
width: 100%;
height: 5000px;
position: relative;
top:50px;
}





_______________________________________________________________________

Add padding to second div equal to height of second div.


.content {
padding-top: 50px;
background: #ccc;
width: 100%;
height: 5000px;
}


When you say scrolling below the back bar, it sounds like you want the content to begin below the back bar. So add some padding to second div to account for presence of fixed div.

_______________________________________________________________________


-
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值