月別アーカイブ: 5月 2021

単純にヘッダーの高さを計算してcontentsにmargin-topつける方法

こんな感じです。jQuery3以上を使っている場合は、functionで囲う必要はありません。

$(window).on('load resize', function() {

var h = $('#header').height();

$( '#contents' )
.css({
'margin-top' : h + 'px',
})

});