Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个position:fixed元素,其高度因页面而异。在这个元素下面,我有一个position:staticorposition:relative元素。有没有办法让静态/相对元素尊重位置的高度:固定元素?
position:fixed
position:static
position:relative
我在下面展示了我的难题:
http://jsfiddle.net/rZ7hc/2/
只是将答案作为实际答案:
不,没有办法让静态/相对元素尊重 position:fixed 元素的高度而不使用 JavaScript。
您可以使用以下 jsfiddle 轻松完成此操作:
$('#not-fixed').css('padding-top', $('#fixed').outerHeight() + 10);
http://jsfiddle.net/VYrsU/1/