简体   繁体   中英

Static or relatively positioned element that respects height of position:fixed element?

I have a position:fixed element, with a height that differs from page to page. Below this element, I have a position:static or position:relative element. Is there a way to have the static/relative element respect the height of the position:fixed element?

I have a fiddle below demonstrating my conundrum:

http://jsfiddle.net/rZ7hc/2/

Just to put the answer as an actual answer:

No, there is no way to have a static/relative element respect the height of the position:fixed element without using JavaScript .

You can do this pretty easily with something like the following jsfiddle:

$('#not-fixed').css('padding-top', $('#fixed').outerHeight() + 10);

http://jsfiddle.net/VYrsU/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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