0
0

More than 1 year has passed since last update.

【JavaScript】ヘッダー position:fixed 要素が下に入り込んでしまう件

Posted at

headerをfixedで固定すると、header以下の要素が下に入り込んでしまいます。
今回はスタイルシートにmargin-topをベタ書きするのではなく、JSで書いてみました。

const header = document.querySelector('header');
const headerHeight = header.offsetHeight;
const main = document.querySelector("main");
main.style.marginTop = `${headerHeight}px`;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0